mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-28 17:02:24 -05:00
Fix css color parse
This commit is contained in:
parent
449c5c3e6d
commit
5904a288e7
3 changed files with 10 additions and 1 deletions
|
@ -1,5 +1,11 @@
|
|||
# Change Log
|
||||
|
||||
## Prebuilt version
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix css color parse (#1629)
|
||||
|
||||
## `0.12.0`
|
||||
|
||||
### News
|
||||
|
|
|
@ -80,7 +80,7 @@ var Color = Base.extend(new function() {
|
|||
} else if (match = string.match(/^(rgb|hsl)a?\((.*)\)$/)) {
|
||||
// RGB / RGBA or HSL / HSLA
|
||||
type = match[1];
|
||||
components = match[2].split(/[,\s]+/g);
|
||||
components = match[2].trim().split(/[,\s]+/g);
|
||||
var isHSL = type === 'hsl';
|
||||
for (var i = 0, l = Math.min(components.length, 4); i < l; i++) {
|
||||
var component = components[i];
|
||||
|
|
|
@ -81,6 +81,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');
|
||||
|
||||
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('hsl(180deg, 20%, 40%)'),
|
||||
new Color({ hue: 180, saturation: 0.2, lightness: 0.4 }),
|
||||
'Color from hsl() string');
|
||||
|
|
Loading…
Reference in a new issue