/* * Paper.js * * This file is part of Paper.js, a JavaScript Vector Graphics Library, * based on Scriptographer.org and designed to be largely API compatible. * http://paperjs.org/ * http://scriptographer.org/ * * Distributed under the MIT license. See LICENSE file for details. * * Copyright (c) 2011, Juerg Lehni & Jonathan Puckey * http://lehni.org/ & http://jonathanpuckey.com/ * * All rights reserved. */ // TODO: support midPoint? (initial tests didn't look nice) var GradientStop = this.GradientStop = Base.extend({ beans: true, initialize: function(arg0, arg1) { if (arg1 === undefined && Array.isArray(arg0)) { // [color, rampPoint] this.setColor(arg0[0]); this.setRampPoint(arg0[1]); } else if (arg0.color) { // stop this.setColor(arg0.color); this.setRampPoint(arg0.rampPoint); } else { // color [, rampPoint] this.setColor(arg0); this.setRampPoint(arg1); } }, clone: function() { return new GradientStop(this._color.clone(), this._rampPoint); }, getRampPoint: function() { return this._rampPoint; }, setRampPoint: function(rampPoint) { this._defaultRamp = rampPoint == null; this._rampPoint = rampPoint || 0; }, getColor: function() { return this._color; }, setColor: function(color) { this._color = Color.read(arguments); }, equals: function(stop) { return stop == this || stop instanceof GradientStop && this._color.equals(stop._color) && this._rampPoint == stop._rampPoint; } });