mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -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.
|
||||
* @return {Number}
|
||||
*/
|
||||
getDistance: function(/* point, squared */) {
|
||||
var point = Point.read(arguments),
|
||||
squared = Base.read(arguments),
|
||||
x = point.x - this.x,
|
||||
getDistance: function(point, squared) {
|
||||
// NOTE: Although we're reading from the argument list, we need the
|
||||
// above arguments to prevent a bean from being created.
|
||||
point = Point.read(arguments);
|
||||
squared = Base.read(arguments);
|
||||
var x = point.x - this.x,
|
||||
y = point.y - this.y,
|
||||
d = x * x + y * y;
|
||||
return squared ? d : Math.sqrt(d);
|
||||
|
@ -636,9 +638,11 @@ var Point = Base.extend(/** @lends Point# */{
|
|||
* @param {Point} point
|
||||
* @return {Number} the angle between the two vectors
|
||||
*/
|
||||
getDirectedAngle: function(/* point */) {
|
||||
var point = Point.read(arguments);
|
||||
return Math.atan2(this.cross(point), this.dot(point)) * 180 / Math.PI;
|
||||
getDirectedAngle: function(point) {
|
||||
// NOTE: Although we're reading from the argument list, we need the
|
||||
// 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 + ', "'
|
||||
+ node.operator[0] + '", 1)');
|
||||
}
|
||||
} else {
|
||||
} else { // AssignmentExpression
|
||||
if (/^.=$/.test(node.operator)
|
||||
&& node.left.type !== 'Literal') {
|
||||
var left = getCode(node.left),
|
||||
|
|
Loading…
Reference in a new issue