|
@@ -4,7 +4,7 @@ import { _Math } from './Math.js';
|
|
* @author mrdoob / http://mrdoob.com/
|
|
* @author mrdoob / http://mrdoob.com/
|
|
*/
|
|
*/
|
|
|
|
|
|
-var ColorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF,
|
|
|
|
|
|
+var _colorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF,
|
|
'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2,
|
|
'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2,
|
|
'brown': 0xA52A2A, 'burlywood': 0xDEB887, 'cadetblue': 0x5F9EA0, 'chartreuse': 0x7FFF00, 'chocolate': 0xD2691E, 'coral': 0xFF7F50,
|
|
'brown': 0xA52A2A, 'burlywood': 0xDEB887, 'cadetblue': 0x5F9EA0, 'chartreuse': 0x7FFF00, 'chocolate': 0xD2691E, 'coral': 0xFF7F50,
|
|
'cornflowerblue': 0x6495ED, 'cornsilk': 0xFFF8DC, 'crimson': 0xDC143C, 'cyan': 0x00FFFF, 'darkblue': 0x00008B, 'darkcyan': 0x008B8B,
|
|
'cornflowerblue': 0x6495ED, 'cornsilk': 0xFFF8DC, 'crimson': 0xDC143C, 'cyan': 0x00FFFF, 'darkblue': 0x00008B, 'darkcyan': 0x008B8B,
|
|
@@ -29,6 +29,9 @@ var ColorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0
|
|
'springgreen': 0x00FF7F, 'steelblue': 0x4682B4, 'tan': 0xD2B48C, 'teal': 0x008080, 'thistle': 0xD8BFD8, 'tomato': 0xFF6347, 'turquoise': 0x40E0D0,
|
|
'springgreen': 0x00FF7F, 'steelblue': 0x4682B4, 'tan': 0xD2B48C, 'teal': 0x008080, 'thistle': 0xD8BFD8, 'tomato': 0xFF6347, 'turquoise': 0x40E0D0,
|
|
'violet': 0xEE82EE, 'wheat': 0xF5DEB3, 'white': 0xFFFFFF, 'whitesmoke': 0xF5F5F5, 'yellow': 0xFFFF00, 'yellowgreen': 0x9ACD32 };
|
|
'violet': 0xEE82EE, 'wheat': 0xF5DEB3, 'white': 0xFFFFFF, 'whitesmoke': 0xF5F5F5, 'yellow': 0xFFFF00, 'yellowgreen': 0x9ACD32 };
|
|
|
|
|
|
|
|
+var _hslA = { h: 0, s: 0, l: 0 };
|
|
|
|
+var _hslB = { h: 0, s: 0, l: 0 };
|
|
|
|
+
|
|
function Color( r, g, b ) {
|
|
function Color( r, g, b ) {
|
|
|
|
|
|
if ( g === undefined && b === undefined ) {
|
|
if ( g === undefined && b === undefined ) {
|
|
@@ -259,7 +262,7 @@ Object.assign( Color.prototype, {
|
|
if ( style && style.length > 0 ) {
|
|
if ( style && style.length > 0 ) {
|
|
|
|
|
|
// color keywords
|
|
// color keywords
|
|
- var hex = ColorKeywords[ style ];
|
|
|
|
|
|
+ var hex = _colorKeywords[ style ];
|
|
|
|
|
|
if ( hex !== undefined ) {
|
|
if ( hex !== undefined ) {
|
|
|
|
|
|
@@ -441,23 +444,17 @@ Object.assign( Color.prototype, {
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- offsetHSL: function () {
|
|
|
|
-
|
|
|
|
- var hsl = {};
|
|
|
|
-
|
|
|
|
- return function ( h, s, l ) {
|
|
|
|
|
|
+ offsetHSL: function ( h, s, l ) {
|
|
|
|
|
|
- this.getHSL( hsl );
|
|
|
|
|
|
+ this.getHSL( _hslA );
|
|
|
|
|
|
- hsl.h += h; hsl.s += s; hsl.l += l;
|
|
|
|
|
|
+ _hslA.h += h; _hslA.s += s; _hslA.l += l;
|
|
|
|
|
|
- this.setHSL( hsl.h, hsl.s, hsl.l );
|
|
|
|
|
|
+ this.setHSL( _hslA.h, _hslA.s, _hslA.l );
|
|
|
|
|
|
- return this;
|
|
|
|
-
|
|
|
|
- };
|
|
|
|
|
|
+ return this;
|
|
|
|
|
|
- }(),
|
|
|
|
|
|
+ },
|
|
|
|
|
|
add: function ( color ) {
|
|
add: function ( color ) {
|
|
|
|
|
|
@@ -529,27 +526,20 @@ Object.assign( Color.prototype, {
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- lerpHSL: function () {
|
|
|
|
|
|
+ lerpHSL: function ( color, alpha ) {
|
|
|
|
|
|
- var hslA = { h: 0, s: 0, l: 0 };
|
|
|
|
- var hslB = { h: 0, s: 0, l: 0 };
|
|
|
|
|
|
+ this.getHSL( _hslA );
|
|
|
|
+ color.getHSL( _hslB );
|
|
|
|
|
|
- return function lerpHSL( color, alpha ) {
|
|
|
|
|
|
+ var h = _Math.lerp( _hslA.h, _hslB.h, alpha );
|
|
|
|
+ var s = _Math.lerp( _hslA.s, _hslB.s, alpha );
|
|
|
|
+ var l = _Math.lerp( _hslA.l, _hslB.l, alpha );
|
|
|
|
|
|
- this.getHSL( hslA );
|
|
|
|
- color.getHSL( hslB );
|
|
|
|
|
|
+ this.setHSL( h, s, l );
|
|
|
|
|
|
- var h = _Math.lerp( hslA.h, hslB.h, alpha );
|
|
|
|
- var s = _Math.lerp( hslA.s, hslB.s, alpha );
|
|
|
|
- var l = _Math.lerp( hslA.l, hslB.l, alpha );
|
|
|
|
-
|
|
|
|
- this.setHSL( h, s, l );
|
|
|
|
-
|
|
|
|
- return this;
|
|
|
|
-
|
|
|
|
- };
|
|
|
|
|
|
+ return this;
|
|
|
|
|
|
- }(),
|
|
|
|
|
|
+ },
|
|
|
|
|
|
equals: function ( c ) {
|
|
equals: function ( c ) {
|
|
|
|
|