mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 14:10:14 -05:00
Revert readNull and clone parameter sequence in arguments reading code.
This commit is contained in:
parent
2e565dcfce
commit
ce7d584c05
7 changed files with 18 additions and 17 deletions
|
@ -158,7 +158,7 @@ var Matrix = Base.extend(/** @lends Matrix# */{
|
|||
// Do not modify scale, center, since that would arguments of which
|
||||
// we're reading from!
|
||||
var _scale = Point.read(arguments),
|
||||
_center = Point.read(arguments, 0, 0, false, true); // readNull
|
||||
_center = Point.read(arguments, 0, 0, true); // readNull
|
||||
if (_center)
|
||||
this.translate(_center);
|
||||
this._a *= _scale.x;
|
||||
|
@ -263,7 +263,7 @@ var Matrix = Base.extend(/** @lends Matrix# */{
|
|||
// Do not modify point, center, since that would arguments of which
|
||||
// we're reading from!
|
||||
var _point = Point.read(arguments),
|
||||
_center = Point.read(arguments, 0, 0, false, true); // readNull
|
||||
_center = Point.read(arguments, 0, 0, true); // readNull
|
||||
if (_center)
|
||||
this.translate(_center);
|
||||
var a = this._a,
|
||||
|
|
|
@ -198,7 +198,7 @@ var Point = Base.extend(/** @lends Point# */{
|
|||
* console.log(point != new Point(1, 1)); // true
|
||||
*/
|
||||
equals: function(point) {
|
||||
point = Point.read(arguments);
|
||||
point = Point.read(arguments, 0, 0, true); // readNull
|
||||
return this.x == point.x && this.y == point.y;
|
||||
},
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* All rights reserved.
|
||||
*/
|
||||
|
||||
// First check if Function#name works, and if not, fix it by injecting a getter
|
||||
// First see if Function#name works, and emulate it through an accessor if not.
|
||||
if (!(function f() {}).name) {
|
||||
Base.define(Function.prototype, 'name', {
|
||||
get: function() {
|
||||
|
@ -160,7 +160,7 @@ Base.inject(/** @lends Base# */{
|
|||
* @param {Boolean} clone controls wether passed objects should be
|
||||
* cloned if they are already provided in the required type
|
||||
*/
|
||||
read: function(list, start, length, clone, readNull) {
|
||||
read: function(list, start, length, readNull, clone) {
|
||||
// See if it's called directly on Base, and if so, read value and
|
||||
// return without object conversion.
|
||||
if (this === Base) {
|
||||
|
@ -216,12 +216,13 @@ Base.inject(/** @lends Base# */{
|
|||
* @param {Boolean} clone controls wether passed objects should be
|
||||
* cloned if they are already provided in the required type
|
||||
*/
|
||||
readAll: function(list, start, clone) {
|
||||
readAll: function(list, start, readNull, clone) {
|
||||
var res = [], entry;
|
||||
for (var i = start || 0, l = list.length; i < l; i++) {
|
||||
res.push(Array.isArray(entry = list[i])
|
||||
? this.read(entry, 0, 0, clone) // 0 for length = max
|
||||
: this.read(list, i, 1, clone));
|
||||
// lenghh = 0 for length = max
|
||||
? this.read(entry, 0, 0, readNull, clone)
|
||||
: this.read(list, i, 1, readNull, clone));
|
||||
}
|
||||
return res;
|
||||
},
|
||||
|
@ -237,10 +238,10 @@ Base.inject(/** @lends Base# */{
|
|||
* @param {Number} start the index at which to start reading in the list
|
||||
* @param {String} name the property name to read from.
|
||||
*/
|
||||
readNamed: function(list, name, start, length, clone, readNull) {
|
||||
readNamed: function(list, name, start, length, readNull, clone) {
|
||||
var value = this.getNamed(list, name);
|
||||
return this.read(value != null ? [value] : list, start, length,
|
||||
clone, readNull);
|
||||
readNull, clone);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,7 @@ Path.inject({ statics: new function() {
|
|||
|
||||
function createRectangle(/* rectangle */) {
|
||||
var rect = Rectangle.readNamed(arguments, 'rectangle'),
|
||||
radius = Size.readNamed(arguments, 'radius', 0, 0, false, true), // readNull
|
||||
radius = Size.readNamed(arguments, 'radius', 0, 0, true), // readNull
|
||||
bl = rect.getBottomLeft(true),
|
||||
tl = rect.getTopLeft(true),
|
||||
tr = rect.getTopRight(true),
|
||||
|
|
|
@ -227,7 +227,7 @@ var Color = Base.extend(new function() {
|
|||
var current = this._components[0];
|
||||
value = Gradient.read(
|
||||
Array.isArray(value) ? value : arguments,
|
||||
0, 0, false, true); // readNull
|
||||
0, 0, true); // readNull
|
||||
if (current !== value) {
|
||||
if (current)
|
||||
current._removeOwner(this);
|
||||
|
@ -244,9 +244,9 @@ var Color = Base.extend(new function() {
|
|||
}
|
||||
: type === 'gradient'
|
||||
? function(value) {
|
||||
// ..., clone, readNull);
|
||||
return Point.read(arguments, 0, 0, true,
|
||||
name === 'highlight');
|
||||
// ..., readNull, clone);
|
||||
return Point.read(arguments, 0, 0,
|
||||
name === 'highlight', true);
|
||||
}
|
||||
: function(value) {
|
||||
return isNaN(value) ? 0
|
||||
|
|
|
@ -143,7 +143,7 @@ var Gradient = Base.extend(/** @lends Gradient# */{
|
|||
if (stops.length < 2)
|
||||
throw new Error(
|
||||
'Gradient stop list needs to contain at least two stops.');
|
||||
this._stops = GradientStop.readAll(stops, 0, true); // clone
|
||||
this._stops = GradientStop.readAll(stops, 0, false, true); // clone
|
||||
// Now reassign ramp points if they were not specified.
|
||||
for (var i = 0, l = this._stops.length; i < l; i++) {
|
||||
var stop = this._stops[i];
|
||||
|
|
|
@ -168,7 +168,7 @@ var Style = Base.extend(new function() {
|
|||
} else if (isColor && !(value && value.constructor === Color)) {
|
||||
// Convert to a Color and stored result of conversion.
|
||||
this._values[key] = value = Color.read(
|
||||
[value], 0, 0, true, true); // readNull
|
||||
[value], 0, 0, true, true); // readNull, clone);
|
||||
if (value)
|
||||
value._owner = this._item;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue