Fix rgb values

Fix was required because values was too big for rgb and breaking the brightness calculation.
Now we have the initial sat (70%) and the reduction to 60 if too bright working again.
This commit is contained in:
John Molakvoæ 2016-04-18 09:22:28 +02:00 committed by skjnldsv
parent d5dbd4e051
commit e11b39a248
1 changed files with 7 additions and 1 deletions

View File

@ -92,7 +92,7 @@
// Init vars
var result = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var rgb = [0, 0, 0];
var sat = 80;
var sat = 70;
var lum = 68;
var modulo = 16;
@ -106,6 +106,12 @@
for(var count=1;count<modulo;count++) {
rgb[count%3] += parseInt(result[count]);
}
// Reduce values bigger than rgb requirements
rgb[0] = rgb[0]%255;
rgb[1] = rgb[1]%255;
rgb[2] = rgb[2]%255;
var hsl = rgbToHsl(rgb[0], rgb[1], rgb[2]);
// Classic formulla to check the brigtness for our eye