diff --git a/src/style/Color.js b/src/style/Color.js index 0b30f649..d699aa50 100644 --- a/src/style/Color.js +++ b/src/style/Color.js @@ -54,7 +54,7 @@ var Color = this.Color = Base.extend(new function() { colorCache = {}, colorCtx; - function nameToRgb(name) { + function nameToRGB(name) { var cached = colorCache[name]; if (!cached) { // Use a canvas to draw to with the given name and then retrieve rgb @@ -81,7 +81,7 @@ var Color = this.Color = Base.extend(new function() { return cached.slice(); } - function hexToRgb(string) { + function hexToRGB(string) { var hex = string.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/); if (hex.length >= 4) { var components = [0, 0, 0]; @@ -499,8 +499,8 @@ var Color = this.Color = Base.extend(new function() { values = slice.call(values, 0, length); } else if (argType === 'string') { components = arg.match(/^#[0-9a-f]{3,6}$/i) - ? hexToRgb(arg) - : nameToRgb(arg); + ? hexToRGB(arg) + : nameToRGB(arg); type = 'rgb'; } else if (argType === 'object') { if (arg._class === 'Color') { @@ -1028,10 +1028,10 @@ var Color = this.Color = Base.extend(new function() { }); }); -// Expose RgbColor, RGBColor, etc. constructors for backward compatibility. +// Expose Color.RGB, etc. constructors, as well as RgbColor, RGBColor, etc.for +// backward compatibility. Base.each(Color._types, function(properties, type) { - var ctor = this[Base.capitalize(type) + 'Color'] = - function(arg) { + var ctor = this[Base.capitalize(type) + 'Color'] = function(arg) { var argType = arg != null && typeof arg, components = argType === 'object' && arg.length != null ? arg @@ -1042,6 +1042,8 @@ Base.each(Color._types, function(properties, type) { ? new Color(type, components) : new Color(arg); }; - if (type.length == 3) - this[type.toUpperCase() + 'Color'] = ctor; + if (type.length == 3) { + var acronym = type.toUpperCase(); + Color[acronym] = this[acronym + 'Color'] = ctor; + } }, this); diff --git a/test/tests/Color.js b/test/tests/Color.js index 05ede856..637e7403 100644 --- a/test/tests/Color.js +++ b/test/tests/Color.js @@ -65,7 +65,7 @@ test('Creating Colors', function() { new Color(1, 0, 0).convert('hsb'), 'Color from hsb object literal'); compareColors(new Color([1, 0, 0]), new Color(1, 0, 0), - 'Rgb Color from array'); + 'RGB Color from array'); compareColors(new Color([1]), new Color(1), 'Gray Color from array'); diff --git a/test/tests/Item_Cloning.js b/test/tests/Item_Cloning.js index 28ad71f9..6b0125e3 100644 --- a/test/tests/Item_Cloning.js +++ b/test/tests/Item_Cloning.js @@ -55,7 +55,6 @@ test('Path#clone() with gradient Color', function() { var colors = ['red', 'green', 'black']; var gradient = new Gradient(colors, true); var color = new Color(gradient, [0, 0], [20, 20], [10, 10]); - var path = new Path([10, 20], [30, 40]); path.fillColor = color; cloneAndCompare(path);