Fix contrast percentage handling, fixes #1144

This commit is contained in:
Synchro
2013-01-23 00:32:41 +01:00
parent 80d9f387c0
commit 3b293be8e2
3 changed files with 9 additions and 1 deletions

View File

@@ -187,7 +187,7 @@ tree.functions = {
if (typeof threshold === 'undefined') {
threshold = 0.43;
} else {
threshold = threshold.value;
threshold = number(threshold);
}
if (((0.2126 * (color.rgb[0]/255) + 0.7152 * (color.rgb[1]/255) + 0.0722 * (color.rgb[2]/255)) * color.alpha) < threshold) {
return light;

View File

@@ -38,6 +38,10 @@
contrast-dark-thresh: #eeeeee;
contrast-high-thresh: #eeeeee;
contrast-low-thresh: #111111;
contrast-light-thresh-per: #111111;
contrast-dark-thresh-per: #eeeeee;
contrast-high-thresh-per: #eeeeee;
contrast-low-thresh-per: #111111;
format: "rgb(32, 128, 64)";
format-string: "hello world";
format-multiple: "hello earth 2";

View File

@@ -42,6 +42,10 @@
contrast-dark-thresh: contrast(#000, #111111, #eeeeee, 0.5);
contrast-high-thresh: contrast(#555, #111111, #eeeeee, 0.6);
contrast-low-thresh: contrast(#555, #111111, #eeeeee, 0.1);
contrast-light-thresh-per: contrast(#fff, #111111, #eeeeee, 50%);
contrast-dark-thresh-per: contrast(#000, #111111, #eeeeee, 50%);
contrast-high-thresh-per: contrast(#555, #111111, #eeeeee, 60%);
contrast-low-thresh-per: contrast(#555, #111111, #eeeeee, 10%);
format: %("rgb(%d, %d, %d)", @r, 128, 64);
format-string: %("hello %s", "world");
format-multiple: %("hello %s %d", "earth", 2);