diff --git a/src/style/Color.js b/src/style/Color.js index 6cf4d737..66293277 100644 --- a/src/style/Color.js +++ b/src/style/Color.js @@ -102,7 +102,7 @@ var Color = Base.extend(new function() { } } else if (i < 3) { // RGB color values to 0..1 - value /= 255; + value /= /%$/.test(component) ? 100 : 255; } components[i] = value; } diff --git a/test/tests/Color.js b/test/tests/Color.js index 363cdcc8..bf572e29 100644 --- a/test/tests/Color.js +++ b/test/tests/Color.js @@ -84,6 +84,9 @@ test('Creating Colors', function() { equals(new Color('rgba( 255, 0, 0, 0.5 )'), new Color(1, 0, 0, 0.5), 'Color from rgba() string 2nd test'); + equals(new Color('rgb(100%, 50%, 0%)'), new Color(1, 0.5, 0), + 'Color from rgb() percenst string'); + equals(new Color('hsl(180deg, 20%, 40%)'), new Color({ hue: 180, saturation: 0.2, lightness: 0.4 }), 'Color from hsl() string');