mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-02 17:50:39 +00:00
Exclude red and green from color generation
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
const d3 = require('d3');
|
||||
|
||||
const PSEUDO_COLOR = '#b1b1cb';
|
||||
const hueScale = d3.scale.linear().range([0, 359]);
|
||||
const lightnessScale = d3.scale.linear().domain([0, 359]).range([0.3, 0.7]);
|
||||
const hueRange = [20, 330]; // exclude red
|
||||
const hueScale = d3.scale.linear().range(hueRange);
|
||||
// map hues to lightness
|
||||
const lightnessScale = d3.scale.linear().domain(hueRange).range([0.3, 0.7]);
|
||||
const startLetterRange = 'A'.charCodeAt();
|
||||
const endLetterRange = 'Z'.charCodeAt();
|
||||
const letterRange = endLetterRange - startLetterRange;
|
||||
@@ -23,8 +25,12 @@ function text2degree(text) {
|
||||
}
|
||||
|
||||
function colors(text, secondText) {
|
||||
const hue = text2degree(text);
|
||||
const saturation = 0.8;
|
||||
let hue = text2degree(text);
|
||||
// skip green and shift to the end of the color wheel
|
||||
if (hue > 70 && hue < 150) {
|
||||
hue += 80;
|
||||
}
|
||||
const saturation = 0.7;
|
||||
let lightness = 0.5;
|
||||
if (secondText) {
|
||||
// reuse text2degree and feed degree to lightness scale
|
||||
|
||||
Reference in New Issue
Block a user