mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-22 07:19:57 -05:00
Make Color#toString() work for gradients.
This commit is contained in:
parent
5209e97c8d
commit
b3256684fb
1 changed files with 8 additions and 3 deletions
|
@ -337,7 +337,7 @@ var Color = this.Color = Base.extend(new function() {
|
||||||
if (this._read && type)
|
if (this._read && type)
|
||||||
read = 1;
|
read = 1;
|
||||||
}
|
}
|
||||||
// Define this GradientColor's unique id.
|
// Define this gradient Color's unique id.
|
||||||
if (type === 'gradient')
|
if (type === 'gradient')
|
||||||
this._id = ++Base._uid;
|
this._id = ++Base._uid;
|
||||||
// Default fallbacks: rgb, black
|
// Default fallbacks: rgb, black
|
||||||
|
@ -486,9 +486,14 @@ var Color = this.Color = Base.extend(new function() {
|
||||||
toString: function() {
|
toString: function() {
|
||||||
var properties = types[this._type],
|
var properties = types[this._type],
|
||||||
parts = [],
|
parts = [],
|
||||||
|
isGradient = this._type === 'gradient',
|
||||||
format = Format.number;
|
format = Format.number;
|
||||||
for (var i = 0, l = properties.length; i < l; i++)
|
for (var i = 0, l = properties.length; i < l; i++) {
|
||||||
parts.push(properties[i] + ': ' + format(this._components[i]));
|
var value = this._components[i];
|
||||||
|
if (value != null)
|
||||||
|
parts.push(properties[i] + ': '
|
||||||
|
+ (isGradient ? value : format(value)));
|
||||||
|
}
|
||||||
if (this._alpha != null)
|
if (this._alpha != null)
|
||||||
parts.push('alpha: ' + format(this._alpha));
|
parts.push('alpha: ' + format(this._alpha));
|
||||||
return '{ ' + parts.join(', ') + ' }';
|
return '{ ' + parts.join(', ') + ' }';
|
||||||
|
|
Loading…
Reference in a new issue