mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Declare functions that work both as getters for beans and also as callalble functions with optional parameters differently, since they do not inject beans anymore if they declare parameters.
This commit is contained in:
parent
dd9340d522
commit
3927836441
2 changed files with 22 additions and 16 deletions
|
@ -227,8 +227,9 @@ var Point = this.Point = Base.extend({
|
|||
*
|
||||
* @param point
|
||||
*/
|
||||
getAngle: function(point) {
|
||||
return this.getAngleInRadians(point) * 180 / Math.PI;
|
||||
getAngle: function(/* point */) {
|
||||
// Hide point from Bootstrap so it injects bean too
|
||||
return this.getAngleInRadians(arguments[0]) * 180 / Math.PI;
|
||||
},
|
||||
|
||||
setAngle: function(angle) {
|
||||
|
@ -241,24 +242,25 @@ var Point = this.Point = Base.extend({
|
|||
return this;
|
||||
},
|
||||
|
||||
getAngleInRadians: function(point) {
|
||||
if (point != undefined) {
|
||||
point = Point.read(arguments);
|
||||
var div = this.getLength() * point.getLength();
|
||||
getAngleInRadians: function(/* point */) {
|
||||
// Hide point from Bootstrap so it injects bean too
|
||||
if (arguments[0] === undefined) {
|
||||
if (this._angle == null)
|
||||
this._angle = Math.atan2(this.y, this.x);
|
||||
return this._angle;
|
||||
} else {
|
||||
var point = Point.read(arguments),
|
||||
div = this.getLength() * point.getLength();
|
||||
if (div == 0) {
|
||||
return NaN;
|
||||
} else {
|
||||
return Math.acos(this.dot(point) / div);
|
||||
}
|
||||
} else {
|
||||
if (this._angle == null)
|
||||
this._angle = Math.atan2(this.y, this.x);
|
||||
return this._angle;
|
||||
}
|
||||
},
|
||||
|
||||
getAngleInDegrees: function(point) {
|
||||
return this.getAngle(point);
|
||||
getAngleInDegrees: function(/* point */) {
|
||||
return this.getAngle(arguments[0]);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -693,16 +693,20 @@ var Path = this.Path = PathItem.extend({
|
|||
|
||||
/**
|
||||
* The bounding rectangle of the item excluding stroke width.
|
||||
* @param matrix optional
|
||||
*/
|
||||
getBounds: function(matrix) {
|
||||
return getBounds(this, matrix);
|
||||
getBounds: function(/* matrix */) {
|
||||
// Pass the matrix hidden from Bootstrap, so it still inject
|
||||
// getBounds as bean too.
|
||||
return getBounds(this, arguments[0]);
|
||||
},
|
||||
|
||||
/**
|
||||
* The bounding rectangle of the item including stroke width.
|
||||
*/
|
||||
getStrokeBounds: function(matrix) {
|
||||
var width = this.getStrokeWidth(),
|
||||
getStrokeBounds: function(/* matrix */) {
|
||||
var matrix = arguments[0], // set #getBounds()
|
||||
width = this.getStrokeWidth(),
|
||||
radius = width / 2,
|
||||
padding = getPenPadding(radius, matrix),
|
||||
join = this.getStrokeJoin(),
|
||||
|
|
Loading…
Reference in a new issue