Rename Color#_colorType to #_type, to prepare for serialization mechanism.

This commit is contained in:
Jürg Lehni 2012-12-27 00:48:56 +01:00
parent 10385267f9
commit 0fb89bd3e0
2 changed files with 15 additions and 15 deletions

View file

@ -216,7 +216,7 @@ var Color = this.Color = Base.extend(new function() {
initialize: function(arg) { initialize: function(arg) {
var isArray = Array.isArray(arg), var isArray = Array.isArray(arg),
type = this._colorType, type = this._type,
res; res;
if (typeof arg === 'object' && !isArray) { if (typeof arg === 'object' && !isArray) {
if (!type) { if (!type) {
@ -297,12 +297,12 @@ var Color = this.Color = Base.extend(new function() {
convert: function(type) { convert: function(type) {
var converter; var converter;
return this._colorType == type return this._type == type
? this.clone() ? this.clone()
: (converter = converters[this._colorType + '-' + type]) : (converter = converters[this._type + '-' + type])
? converter(this) ? converter(this)
: converters['rgb-' + type]( : converters['rgb-' + type](
converters[this._colorType + '-rgb'](this)); converters[this._type + '-rgb'](this));
}, },
statics: /** @lends Color */{ statics: /** @lends Color */{
@ -313,8 +313,8 @@ var Color = this.Color = Base.extend(new function() {
* @ignore * @ignore
*/ */
extend: function(src) { extend: function(src) {
if (src._colorType) { if (src._type) {
var comps = components[src._colorType]; var comps = components[src._type];
// Automatically produce the _components field, adding alpha // Automatically produce the _components field, adding alpha
src._components = comps.concat(['alpha']); src._components = comps.concat(['alpha']);
Base.each(comps, function(name) { Base.each(comps, function(name) {
@ -335,7 +335,7 @@ var Color = this.Color = Base.extend(new function() {
}; };
}, src); }, src);
} }
return this.base(src); return this.base.apply(this, arguments);
}, },
random: function() { random: function() {
@ -357,7 +357,7 @@ var Color = this.Color = Base.extend(new function() {
fields['set' + part] = function(value) { fields['set' + part] = function(value) {
var color = this.convert(type); var color = this.convert(type);
color[component] = value; color[component] = value;
color = color.convert(this._colorType); color = color.convert(this._type);
for (var i = 0, l = this._components.length; i < l; i++) { for (var i = 0, l = this._components.length; i < l; i++) {
var key = this._components[i]; var key = this._components[i];
this[key] = color[key]; this[key] = color[key];
@ -389,7 +389,7 @@ var Color = this.Color = Base.extend(new function() {
* console.log(color.type); // 'rgb' * console.log(color.type); // 'rgb'
*/ */
getType: function() { getType: function() {
return this._colorType; return this._type;
}, },
getComponents: function() { getComponents: function() {
@ -448,7 +448,7 @@ var Color = this.Color = Base.extend(new function() {
* @return {Boolean} {@true if the colors are the same} * @return {Boolean} {@true if the colors are the same}
*/ */
equals: function(color) { equals: function(color) {
if (color && color._colorType === this._colorType) { if (color && color._type === this._type) {
for (var i = 0, l = this._components.length; i < l; i++) { for (var i = 0, l = this._components.length; i < l; i++) {
var component = '_' + this._components[i]; var component = '_' + this._components[i];
if (this[component] !== color[component]) if (this[component] !== color[component])
@ -664,7 +664,7 @@ var GrayColor = this.GrayColor = Color.extend(/** @lends GrayColor# */{
* @type Number * @type Number
*/ */
_colorType: 'gray' _type: 'gray'
}); });
/** /**
@ -753,7 +753,7 @@ var RgbColor = this.RgbColor = this.RGBColor = Color.extend(/** @lends RgbColor#
* circle.fillColor.blue = 1; * circle.fillColor.blue = 1;
*/ */
_colorType: 'rgb' _type: 'rgb'
}); });
/** /**
@ -831,7 +831,7 @@ var HsbColor = this.HsbColor = this.HSBColor = Color.extend(/** @lends HsbColor#
* @type Number * @type Number
*/ */
_colorType: 'hsb' _type: 'hsb'
}); });
@ -892,5 +892,5 @@ var HslColor = this.HslColor = this.HSLColor = Color.extend(/** @lends HslColor#
* @type Number * @type Number
*/ */
_colorType: 'hsl' _type: 'hsl'
}); });

View file

@ -248,7 +248,7 @@ var GradientColor = this.GradientColor = Color.extend(/** @lends GradientColor#
* @return {@true the GradientColor is the same} * @return {@true the GradientColor is the same}
*/ */
equals: function(color) { equals: function(color) {
return color == this || color && color._colorType === this._colorType return color == this || color && color._type === this._type
&& this.gradient.equals(color.gradient) && this.gradient.equals(color.gradient)
&& this._origin.equals(color._origin) && this._origin.equals(color._origin)
&& this._destination.equals(color._destination); && this._destination.equals(color._destination);