mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Implement argument reading for Gradient objects.
This commit is contained in:
parent
b9532f6a1a
commit
26efbdb451
3 changed files with 14 additions and 9 deletions
|
@ -7,11 +7,11 @@
|
|||
<script type="text/javascript" src="../../dist/paper.js"></script>
|
||||
<script type="text/paperscript" canvas="canvas1">
|
||||
var path = new Path.Circle(view.center, view.bounds.height * 0.4);
|
||||
var gradient = new Gradient(['yellow', 'red', 'black'], true);
|
||||
var from = path.position;
|
||||
var to = path.bounds.rightCenter;
|
||||
var gradientColor = new Color(gradient, from, to);
|
||||
path.fillColor = gradientColor;
|
||||
path.fillColor = {
|
||||
gradient: [['yellow', 'red', 'black'], true],
|
||||
origin: path.position,
|
||||
destination: path.bounds.rightCenter
|
||||
}
|
||||
path.strokeColor = 'black';
|
||||
window._json = project.exportJson();
|
||||
console.log(window._json);
|
||||
|
|
|
@ -226,6 +226,9 @@ var Color = this.Color = Base.extend(new function() {
|
|||
parser = parsers[type][index] = name === 'gradient'
|
||||
? function(value) {
|
||||
var current = this._components[0];
|
||||
value = Gradient.read(
|
||||
Array.isArray(value) ? value : arguments,
|
||||
0, 0, false, true); // readNull
|
||||
if (current !== value) {
|
||||
if (current)
|
||||
current._removeOwner(this);
|
||||
|
|
|
@ -21,10 +21,12 @@ var Gradient = this.Gradient = Base.extend(/** @lends Gradient# */{
|
|||
initialize: function(stops, radial) {
|
||||
// Define this Gradient's unique id.
|
||||
this._id = ++Base._uid;
|
||||
this.setStops(stops || ['white', 'black']);
|
||||
// Support old version of string type argument and new radial boolean.
|
||||
this.setRadial(typeof radial === 'string' && radial === 'radial'
|
||||
|| radial || false);
|
||||
if (!stops || !this._set(stops)) {
|
||||
this.setStops(stops || ['white', 'black']);
|
||||
// Support old string type argument and new radial boolean.
|
||||
this.setRadial(typeof radial === 'string' && radial === 'radial'
|
||||
|| radial || false);
|
||||
}
|
||||
},
|
||||
|
||||
_serialize: function(options, dictionary) {
|
||||
|
|
Loading…
Reference in a new issue