mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Undo commit 4445376c0204cb5a2e408c64b77a5b6fa09305ba since it clashes with magnification.
This commit is contained in:
parent
1509a934b0
commit
734cc1cc61
7 changed files with 29 additions and 30 deletions
7
lib/bootstrap.js
vendored
7
lib/bootstrap.js
vendored
|
@ -147,11 +147,8 @@ var Base = new function() { // Bootstrap scope
|
||||||
// with optional arguments and as beans should not declare
|
// with optional arguments and as beans should not declare
|
||||||
// the parameters and use the arguments array internally
|
// the parameters and use the arguments array internally
|
||||||
// instead.
|
// instead.
|
||||||
if (beans && (bean = name.match(/^(get|is)(([A-Z])(.*))$/))
|
if (beans && val.length === 0
|
||||||
// Reg-exp to detect non-hidden parameters. We only
|
&& (bean = name.match(/^(get|is)(([A-Z])(.*))$/)))
|
||||||
// produce beans if there are no parameters or only
|
|
||||||
// hidden ones:
|
|
||||||
&& !/^function\s*\(.*\b[^_,].*\)/.test(val))
|
|
||||||
beans.push([ bean[3].toLowerCase() + bean[4], bean[2] ]);
|
beans.push([ bean[3].toLowerCase() + bean[4], bean[2] ]);
|
||||||
}
|
}
|
||||||
// No need to look up getter if this is a function already.
|
// No need to look up getter if this is a function already.
|
||||||
|
|
|
@ -504,9 +504,9 @@ var Point = this.Point = Base.extend(/** @lends Point# */{
|
||||||
* @bean
|
* @bean
|
||||||
* @type Number
|
* @type Number
|
||||||
*/
|
*/
|
||||||
getAngle: function(_point) {
|
getAngle: function(/* point */) {
|
||||||
// Hide parameters from Bootstrap so it injects bean too
|
// Hide parameters from Bootstrap so it injects bean too
|
||||||
return this.getAngleInRadians(_point) * 180 / Math.PI;
|
return this.getAngleInRadians(arguments[0]) * 180 / Math.PI;
|
||||||
},
|
},
|
||||||
|
|
||||||
setAngle: function(angle) {
|
setAngle: function(angle) {
|
||||||
|
@ -542,9 +542,9 @@ var Point = this.Point = Base.extend(/** @lends Point# */{
|
||||||
* @bean
|
* @bean
|
||||||
* @type Number
|
* @type Number
|
||||||
*/
|
*/
|
||||||
getAngleInRadians: function(_point) {
|
getAngleInRadians: function(/* point */) {
|
||||||
// Hide parameters from Bootstrap so it injects bean too
|
// Hide parameters from Bootstrap so it injects bean too
|
||||||
if (_point === undefined) {
|
if (arguments[0] === undefined) {
|
||||||
if (this._angle == null)
|
if (this._angle == null)
|
||||||
this._angle = Math.atan2(this.y, this.x);
|
this._angle = Math.atan2(this.y, this.x);
|
||||||
return this._angle;
|
return this._angle;
|
||||||
|
@ -559,8 +559,8 @@ var Point = this.Point = Base.extend(/** @lends Point# */{
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getAngleInDegrees: function(_point) {
|
getAngleInDegrees: function(/* point */) {
|
||||||
return this.getAngle(_point);
|
return this.getAngle(arguments[0]);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -167,10 +167,10 @@ var Rectangle = this.Rectangle = Base.extend(/** @lends Rectangle# */{
|
||||||
* @type Point
|
* @type Point
|
||||||
* @bean
|
* @bean
|
||||||
*/
|
*/
|
||||||
getPoint: function(_dontLink) {
|
getPoint: function(/* dontLink */) {
|
||||||
// Pass on the optional argument _dontLink which tells LinkedPoint to
|
// Pass on the optional argument _dontLink which tells LinkedPoint to
|
||||||
// produce a normal point instead. Used internally for speed reasons.
|
// produce a normal point instead. Used internally for speed reasons.
|
||||||
return LinkedPoint.create(this, 'setPoint', this.x, this.y, _dontLink);
|
return LinkedPoint.create(this, 'setPoint', this.x, this.y, arguments[0]);
|
||||||
},
|
},
|
||||||
|
|
||||||
setPoint: function(point) {
|
setPoint: function(point) {
|
||||||
|
@ -187,9 +187,9 @@ var Rectangle = this.Rectangle = Base.extend(/** @lends Rectangle# */{
|
||||||
* @type Size
|
* @type Size
|
||||||
* @bean
|
* @bean
|
||||||
*/
|
*/
|
||||||
getSize: function(_dontLink) {
|
getSize: function(/* dontLink */) {
|
||||||
return LinkedSize.create(this, 'setSize', this.width, this.height,
|
return LinkedSize.create(this, 'setSize', this.width, this.height,
|
||||||
_dontLink);
|
arguments[0]);
|
||||||
},
|
},
|
||||||
|
|
||||||
setSize: function(size) {
|
setSize: function(size) {
|
||||||
|
@ -307,9 +307,9 @@ var Rectangle = this.Rectangle = Base.extend(/** @lends Rectangle# */{
|
||||||
* @type Point
|
* @type Point
|
||||||
* @bean
|
* @bean
|
||||||
*/
|
*/
|
||||||
getCenter: function(_dontLink) {
|
getCenter: function(/* dontLink */) {
|
||||||
return LinkedPoint.create(this, 'setCenter',
|
return LinkedPoint.create(this, 'setCenter',
|
||||||
this.getCenterX(), this.getCenterY(), _dontLink);
|
this.getCenterX(), this.getCenterY(), arguments[0]);
|
||||||
},
|
},
|
||||||
|
|
||||||
setCenter: function(point) {
|
setCenter: function(point) {
|
||||||
|
@ -725,9 +725,9 @@ var Rectangle = this.Rectangle = Base.extend(/** @lends Rectangle# */{
|
||||||
setY = 'set' + y,
|
setY = 'set' + y,
|
||||||
get = 'get' + part,
|
get = 'get' + part,
|
||||||
set = 'set' + part;
|
set = 'set' + part;
|
||||||
this[get] = function(_dontLink) {
|
this[get] = function(/* dontLink */) {
|
||||||
return LinkedPoint.create(this, set,
|
return LinkedPoint.create(this, set,
|
||||||
this[getX](), this[getY](), _dontLink);
|
this[getX](), this[getY](), arguments[0]);
|
||||||
};
|
};
|
||||||
this[set] = function(point) {
|
this[set] = function(point) {
|
||||||
point = Point.read(arguments);
|
point = Point.read(arguments);
|
||||||
|
|
|
@ -512,7 +512,7 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{
|
||||||
* // Move the circle 100 points to the right
|
* // Move the circle 100 points to the right
|
||||||
* circle.position.x += 100;
|
* circle.position.x += 100;
|
||||||
*/
|
*/
|
||||||
getPosition: function(_dontLink) {
|
getPosition: function(/* dontLink */) {
|
||||||
// Cache position value.
|
// Cache position value.
|
||||||
// Pass true for dontLink in getCenter(), so receive back a normal point
|
// Pass true for dontLink in getCenter(), so receive back a normal point
|
||||||
var pos = this._position
|
var pos = this._position
|
||||||
|
@ -521,7 +521,7 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{
|
||||||
// use them to calculate the difference in #setPosition, as when it is
|
// use them to calculate the difference in #setPosition, as when it is
|
||||||
// modified, it would hold new values already and only then cause the
|
// modified, it would hold new values already and only then cause the
|
||||||
// calling of #setPosition.
|
// calling of #setPosition.
|
||||||
return _dontLink ? pos
|
return arguments[0] ? pos
|
||||||
: LinkedPoint.create(this, 'setPosition', pos.x, pos.y);
|
: LinkedPoint.create(this, 'setPosition', pos.x, pos.y);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -565,13 +565,13 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{
|
||||||
// Produce getters for bounds properties. These handle caching, matrices
|
// Produce getters for bounds properties. These handle caching, matrices
|
||||||
// and redirect the call to the private _getBounds, which can be
|
// and redirect the call to the private _getBounds, which can be
|
||||||
// overridden by subclasses, see below.
|
// overridden by subclasses, see below.
|
||||||
this[name] = function(_matrix) {
|
this[name] = function(/* matrix */) {
|
||||||
var getter = this._boundsGetter,
|
var getter = this._boundsGetter,
|
||||||
// Allow subclasses to override _boundsGetter if they use
|
// Allow subclasses to override _boundsGetter if they use
|
||||||
// the same calculations for multiple type of bounds.
|
// the same calculations for multiple type of bounds.
|
||||||
// The default is name:
|
// The default is name:
|
||||||
bounds = this._getCachedBounds(typeof getter == 'string'
|
bounds = this._getCachedBounds(typeof getter == 'string'
|
||||||
? getter : getter && getter[name] || name, _matrix);
|
? getter : getter && getter[name] || name, arguments[0]);
|
||||||
// If we're returning 'bounds', create a LinkedRectangle that uses
|
// If we're returning 'bounds', create a LinkedRectangle that uses
|
||||||
// the setBounds() setter to update the Item whenever the bounds are
|
// the setBounds() setter to update the Item whenever the bounds are
|
||||||
// changed:
|
// changed:
|
||||||
|
|
|
@ -154,13 +154,13 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{
|
||||||
* @type Context
|
* @type Context
|
||||||
* @bean
|
* @bean
|
||||||
*/
|
*/
|
||||||
getContext: function(_notifyChange) {
|
getContext: function(/* notifyChange */) {
|
||||||
if (!this._context)
|
if (!this._context)
|
||||||
this._context = this.getCanvas().getContext('2d');
|
this._context = this.getCanvas().getContext('2d');
|
||||||
// Support a hidden parameter that indicates if the context will be used
|
// Support a hidden parameter that indicates if the context will be used
|
||||||
// to modify the Raster object. We can notify such changes ahead since
|
// to modify the Raster object. We can notify such changes ahead since
|
||||||
// they are only used afterwards for redrawing.
|
// they are only used afterwards for redrawing.
|
||||||
if (_notifyChange)
|
if (arguments[0])
|
||||||
this._changed(/*#=*/ Change.PIXELS);
|
this._changed(/*#=*/ Change.PIXELS);
|
||||||
return this._context;
|
return this._context;
|
||||||
},
|
},
|
||||||
|
|
|
@ -235,11 +235,13 @@ var Curve = this.Curve = Base.extend(/** @lends Curve# */{
|
||||||
* @bean
|
* @bean
|
||||||
*/
|
*/
|
||||||
// Hide parameters from Bootstrap so it injects bean too
|
// Hide parameters from Bootstrap so it injects bean too
|
||||||
getLength: function(_from, _to) {
|
getLength: function(/* from, to */) {
|
||||||
var fullLength = arguments.length == 0 || _from == 0 && _to == 1;
|
var from = arguments[0],
|
||||||
|
to = arguments[1],
|
||||||
|
fullLength = arguments.length == 0 || from == 0 && to == 1;
|
||||||
if (fullLength && this._length != null)
|
if (fullLength && this._length != null)
|
||||||
return this._length;
|
return this._length;
|
||||||
var length = Curve.getLength(this.getValues(), _from, _to);
|
var length = Curve.getLength(this.getValues(), from, to);
|
||||||
if (fullLength)
|
if (fullLength)
|
||||||
this._length = length;
|
this._length = length;
|
||||||
return length;
|
return length;
|
||||||
|
|
|
@ -131,7 +131,7 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
|
||||||
* @type Curve[]
|
* @type Curve[]
|
||||||
* @bean
|
* @bean
|
||||||
*/
|
*/
|
||||||
getCurves: function(_includeFill) {
|
getCurves: function(/* includeFill */) {
|
||||||
var curves = this._curves,
|
var curves = this._curves,
|
||||||
segments = this._segments;
|
segments = this._segments;
|
||||||
if (!curves) {
|
if (!curves) {
|
||||||
|
@ -148,7 +148,7 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
|
||||||
// If we're asked to include the closing curve for fill, even if the
|
// If we're asked to include the closing curve for fill, even if the
|
||||||
// path is not closed for stroke, create a new uncached array and add
|
// path is not closed for stroke, create a new uncached array and add
|
||||||
// the closing curve. Used in Path#contains()
|
// the closing curve. Used in Path#contains()
|
||||||
if (_includeFill && !this._closed && this._style._fillColor) {
|
if (arguments[0] && !this._closed && this._style._fillColor) {
|
||||||
curves = curves.concat([
|
curves = curves.concat([
|
||||||
Curve.create(this, segments[segments.length - 1], segments[0])
|
Curve.create(this, segments[segments.length - 1], segments[0])
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Reference in a new issue