mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-28 17:02:24 -05:00
Fix parsing of rgb color string with percentages
This commit is contained in:
parent
7dad1a495d
commit
871531b46a
2 changed files with 4 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in a new issue