|
@@ -176,27 +176,27 @@ class Color {
|
|
case 'rgb':
|
|
case 'rgb':
|
|
case 'rgba':
|
|
case 'rgba':
|
|
|
|
|
|
- if ( color = /^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec( components ) ) {
|
|
|
|
|
|
+ if ( color = /^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) {
|
|
|
|
|
|
// rgb(255,0,0) rgba(255,0,0,0.5)
|
|
// rgb(255,0,0) rgba(255,0,0,0.5)
|
|
this.r = Math.min( 255, parseInt( color[ 1 ], 10 ) ) / 255;
|
|
this.r = Math.min( 255, parseInt( color[ 1 ], 10 ) ) / 255;
|
|
this.g = Math.min( 255, parseInt( color[ 2 ], 10 ) ) / 255;
|
|
this.g = Math.min( 255, parseInt( color[ 2 ], 10 ) ) / 255;
|
|
this.b = Math.min( 255, parseInt( color[ 3 ], 10 ) ) / 255;
|
|
this.b = Math.min( 255, parseInt( color[ 3 ], 10 ) ) / 255;
|
|
|
|
|
|
- handleAlpha( color[ 5 ] );
|
|
|
|
|
|
+ handleAlpha( color[ 4 ] );
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- if ( color = /^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec( components ) ) {
|
|
|
|
|
|
+ if ( color = /^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) {
|
|
|
|
|
|
// rgb(100%,0%,0%) rgba(100%,0%,0%,0.5)
|
|
// rgb(100%,0%,0%) rgba(100%,0%,0%,0.5)
|
|
this.r = Math.min( 100, parseInt( color[ 1 ], 10 ) ) / 100;
|
|
this.r = Math.min( 100, parseInt( color[ 1 ], 10 ) ) / 100;
|
|
this.g = Math.min( 100, parseInt( color[ 2 ], 10 ) ) / 100;
|
|
this.g = Math.min( 100, parseInt( color[ 2 ], 10 ) ) / 100;
|
|
this.b = Math.min( 100, parseInt( color[ 3 ], 10 ) ) / 100;
|
|
this.b = Math.min( 100, parseInt( color[ 3 ], 10 ) ) / 100;
|
|
|
|
|
|
- handleAlpha( color[ 5 ] );
|
|
|
|
|
|
+ handleAlpha( color[ 4 ] );
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
@@ -207,14 +207,14 @@ class Color {
|
|
case 'hsl':
|
|
case 'hsl':
|
|
case 'hsla':
|
|
case 'hsla':
|
|
|
|
|
|
- if ( color = /^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec( components ) ) {
|
|
|
|
|
|
+ if ( color = /^(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) {
|
|
|
|
|
|
// hsl(120,50%,50%) hsla(120,50%,50%,0.5)
|
|
// hsl(120,50%,50%) hsla(120,50%,50%,0.5)
|
|
const h = parseFloat( color[ 1 ] ) / 360;
|
|
const h = parseFloat( color[ 1 ] ) / 360;
|
|
const s = parseInt( color[ 2 ], 10 ) / 100;
|
|
const s = parseInt( color[ 2 ], 10 ) / 100;
|
|
const l = parseInt( color[ 3 ], 10 ) / 100;
|
|
const l = parseInt( color[ 3 ], 10 ) / 100;
|
|
|
|
|
|
- handleAlpha( color[ 5 ] );
|
|
|
|
|
|
+ handleAlpha( color[ 4 ] );
|
|
|
|
|
|
return this.setHSL( h, s, l );
|
|
return this.setHSL( h, s, l );
|
|
|
|
|
|
@@ -224,7 +224,7 @@ class Color {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- } else if ( m = /^\#([A-Fa-f0-9]+)$/.exec( style ) ) {
|
|
|
|
|
|
+ } else if ( m = /^\#([A-Fa-f\d]+)$/.exec( style ) ) {
|
|
|
|
|
|
// hex color
|
|
// hex color
|
|
|
|
|