Exclude red and green from color generation

This commit is contained in:
David Kaltschmidt
2015-11-20 15:23:44 +01:00
parent bf9b5bf947
commit 104f1574c8

View File

@@ -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