mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-07-10 03:34:04 -04:00
Allow implicit Gradient declaration in Color object literals.
This commit is contained in:
parent
0d125e1a12
commit
9d0b9dc4c6
2 changed files with 18 additions and 4 deletions
|
@ -8,7 +8,9 @@
|
||||||
<script type="text/paperscript" canvas="canvas1">
|
<script type="text/paperscript" canvas="canvas1">
|
||||||
var path = new Path.Circle(view.center, view.bounds.height * 0.4);
|
var path = new Path.Circle(view.center, view.bounds.height * 0.4);
|
||||||
path.fillColor = {
|
path.fillColor = {
|
||||||
gradient: [['yellow', 'red', 'black'], true],
|
// gradient: [['yellow', 'red', 'black'], true],
|
||||||
|
stops: ['yellow', 'red', 'black'],
|
||||||
|
radial: true,
|
||||||
origin: path.position,
|
origin: path.position,
|
||||||
destination: path.bounds.rightCenter
|
destination: path.bounds.rightCenter
|
||||||
}
|
}
|
||||||
|
|
|
@ -504,7 +504,7 @@ var Color = this.Color = Base.extend(new function() {
|
||||||
? 'lightness' in arg
|
? 'lightness' in arg
|
||||||
? 'hsl'
|
? 'hsl'
|
||||||
: 'hsb'
|
: 'hsb'
|
||||||
: 'gradient' in arg
|
: 'gradient' in arg || 'stops' in arg
|
||||||
? 'gradient'
|
? 'gradient'
|
||||||
: 'gray' in arg
|
: 'gray' in arg
|
||||||
? 'gray'
|
? 'gray'
|
||||||
|
@ -513,8 +513,20 @@ var Color = this.Color = Base.extend(new function() {
|
||||||
var properties = types[type];
|
var properties = types[type];
|
||||||
parse = parsers[type];
|
parse = parsers[type];
|
||||||
this._components = components = [];
|
this._components = components = [];
|
||||||
for (var i = 0, l = properties.length; i < l; i++)
|
for (var i = 0, l = properties.length; i < l; i++) {
|
||||||
components[i] = parse[i].call(this, arg[properties[i]]);
|
var value = arg[properties[i]];
|
||||||
|
// Allow implicit definition of gradients through
|
||||||
|
// stops / radial properties. Conversion happens
|
||||||
|
// here on the fly:
|
||||||
|
if (value == null && i === 0 && type === 'gradient'
|
||||||
|
&& 'stops' in arg) {
|
||||||
|
value = {
|
||||||
|
stops: arg.stops,
|
||||||
|
radial: arg.radial
|
||||||
|
};
|
||||||
|
}
|
||||||
|
components[i] = parse[i].call(this, value);
|
||||||
|
}
|
||||||
alpha = arg.alpha;
|
alpha = arg.alpha;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue