mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Prevent unnecessary beans from being created.
This commit is contained in:
parent
dd37704f2c
commit
7291956155
2 changed files with 12 additions and 8 deletions
|
@ -449,10 +449,12 @@ var Point = Base.extend(/** @lends Point# */{
|
||||||
* remain squared, or its square root should be calculated.
|
* remain squared, or its square root should be calculated.
|
||||||
* @return {Number}
|
* @return {Number}
|
||||||
*/
|
*/
|
||||||
getDistance: function(/* point, squared */) {
|
getDistance: function(point, squared) {
|
||||||
var point = Point.read(arguments),
|
// NOTE: Although we're reading from the argument list, we need the
|
||||||
squared = Base.read(arguments),
|
// above arguments to prevent a bean from being created.
|
||||||
x = point.x - this.x,
|
point = Point.read(arguments);
|
||||||
|
squared = Base.read(arguments);
|
||||||
|
var x = point.x - this.x,
|
||||||
y = point.y - this.y,
|
y = point.y - this.y,
|
||||||
d = x * x + y * y;
|
d = x * x + y * y;
|
||||||
return squared ? d : Math.sqrt(d);
|
return squared ? d : Math.sqrt(d);
|
||||||
|
@ -636,9 +638,11 @@ var Point = Base.extend(/** @lends Point# */{
|
||||||
* @param {Point} point
|
* @param {Point} point
|
||||||
* @return {Number} the angle between the two vectors
|
* @return {Number} the angle between the two vectors
|
||||||
*/
|
*/
|
||||||
getDirectedAngle: function(/* point */) {
|
getDirectedAngle: function(point) {
|
||||||
var point = Point.read(arguments);
|
// NOTE: Although we're reading from the argument list, we need the
|
||||||
return Math.atan2(this.cross(point), this.dot(point)) * 180 / Math.PI;
|
// above argument to prevent a bean from being created.
|
||||||
|
point = Point.read(arguments);
|
||||||
|
return Math.atan2(this.cross(_point), this.dot(_point)) * 180 / Math.PI;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -207,7 +207,7 @@ var PaperScript = Base.exports.PaperScript = (function() {
|
||||||
replaceCode(node, arg + ' = _$_(' + arg + ', "'
|
replaceCode(node, arg + ' = _$_(' + arg + ', "'
|
||||||
+ node.operator[0] + '", 1)');
|
+ node.operator[0] + '", 1)');
|
||||||
}
|
}
|
||||||
} else {
|
} else { // AssignmentExpression
|
||||||
if (/^.=$/.test(node.operator)
|
if (/^.=$/.test(node.operator)
|
||||||
&& node.left.type !== 'Literal') {
|
&& node.left.type !== 'Literal') {
|
||||||
var left = getCode(node.left),
|
var left = getCode(node.left),
|
||||||
|
|
Loading…
Reference in a new issue