mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Various small code cleanups.
This commit is contained in:
parent
b0282b9bd4
commit
41120cf4d9
8 changed files with 13 additions and 13 deletions
|
@ -39,7 +39,7 @@ var Line = this.Line = Base.extend({
|
||||||
// Epsilon tolerance
|
// Epsilon tolerance
|
||||||
if (Math.abs(cross) <= 10e-6)
|
if (Math.abs(cross) <= 10e-6)
|
||||||
return null;
|
return null;
|
||||||
var v = line.point.subtract(this.point)
|
var v = line.point.subtract(this.point),
|
||||||
t1 = v.cross(line.vector) / cross,
|
t1 = v.cross(line.vector) / cross,
|
||||||
t2 = v.cross(this.vector) / cross;
|
t2 = v.cross(this.vector) / cross;
|
||||||
// Check the ranges of t parameters if the line is not allowed to
|
// Check the ranges of t parameters if the line is not allowed to
|
||||||
|
|
|
@ -310,7 +310,7 @@ var LinkedRectangle = Rectangle.extend({
|
||||||
var internal = '_' + key;
|
var internal = '_' + key;
|
||||||
this['get' + part] = function() {
|
this['get' + part] = function() {
|
||||||
return this[internal];
|
return this[internal];
|
||||||
}
|
};
|
||||||
|
|
||||||
this['set' + part] = function(value) {
|
this['set' + part] = function(value) {
|
||||||
this[internal] = value;
|
this[internal] = value;
|
||||||
|
@ -318,7 +318,7 @@ var LinkedRectangle = Rectangle.extend({
|
||||||
// _dontNotify, as it will notify itself
|
// _dontNotify, as it will notify itself
|
||||||
if (!this._dontNotify)
|
if (!this._dontNotify)
|
||||||
this._owner[this._set](this);
|
this._owner[this._set](this);
|
||||||
}
|
};
|
||||||
}, Base.each(['Point', 'Size', 'Center',
|
}, Base.each(['Point', 'Size', 'Center',
|
||||||
'Left', 'Top', 'Right', 'Bottom', 'CenterX', 'CenterY',
|
'Left', 'Top', 'Right', 'Bottom', 'CenterX', 'CenterY',
|
||||||
'TopLeft', 'TopRight', 'BottomLeft', 'BottomRight',
|
'TopLeft', 'TopRight', 'BottomLeft', 'BottomRight',
|
||||||
|
@ -334,7 +334,7 @@ var LinkedRectangle = Rectangle.extend({
|
||||||
delete this._dontNotify;
|
delete this._dontNotify;
|
||||||
this._owner[this._set](this);
|
this._owner[this._set](this);
|
||||||
return this;
|
return this;
|
||||||
}
|
};
|
||||||
}, { beans: true })
|
}, { beans: true })
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,7 +20,7 @@ var Gradient = this.Gradient = Base.extend({
|
||||||
// TODO: should type here be called 'radial' and have it
|
// TODO: should type here be called 'radial' and have it
|
||||||
// receive a boolean value?
|
// receive a boolean value?
|
||||||
initialize: function(stops, type) {
|
initialize: function(stops, type) {
|
||||||
if(!stops) {
|
if (!stops) {
|
||||||
stops = [new GradientStop('white', 0),
|
stops = [new GradientStop('white', 0),
|
||||||
new GradientStop('black', 1)];
|
new GradientStop('black', 1)];
|
||||||
}
|
}
|
||||||
|
@ -36,12 +36,12 @@ var Gradient = this.Gradient = Base.extend({
|
||||||
if (stops.length < 2)
|
if (stops.length < 2)
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Gradient stop list needs to contain at least two stops.');
|
'Gradient stop list needs to contain at least two stops.');
|
||||||
if(!(stops[0] instanceof GradientStop)) {
|
if (!(stops[0] instanceof GradientStop)) {
|
||||||
for(var i = 0, l = stops.length; i < l; i++) {
|
for(var i = 0, l = stops.length; i < l; i++) {
|
||||||
var rampPoint;
|
var rampPoint;
|
||||||
var stop = stops[i];
|
var stop = stops[i];
|
||||||
// If it is an array, the second argument is the rampPoint:
|
// If it is an array, the second argument is the rampPoint:
|
||||||
if(stop.length) {
|
if (stop.length) {
|
||||||
rampPoint = stop[1];
|
rampPoint = stop[1];
|
||||||
stop = stop[0];
|
stop = stop[0];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -66,7 +66,7 @@ var Layer = this.Layer = Group.extend({
|
||||||
} else {
|
} else {
|
||||||
return this.base(item);
|
return this.base(item);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -67,7 +67,7 @@ var Raster = this.Raster = Item.extend({
|
||||||
* Pixels per inch of the raster at it's current size.
|
* Pixels per inch of the raster at it's current size.
|
||||||
*/
|
*/
|
||||||
getPpi: function() {
|
getPpi: function() {
|
||||||
var matrix = this.matrix;
|
var matrix = this.matrix,
|
||||||
orig = new Point(0, 0).transform(matrix),
|
orig = new Point(0, 0).transform(matrix),
|
||||||
u = new Point(1, 0).transform(matrix).subtract(orig),
|
u = new Point(1, 0).transform(matrix).subtract(orig),
|
||||||
v = new Point(0, 1).transform(matrix).subtract(orig);
|
v = new Point(0, 1).transform(matrix).subtract(orig);
|
||||||
|
|
|
@ -278,7 +278,7 @@ var Curve = this.Curve = Base.extend({
|
||||||
case 2: // normal
|
case 2: // normal
|
||||||
// Simply use the derivation of the bezier function for both
|
// Simply use the derivation of the bezier function for both
|
||||||
// the x and y coordinates:
|
// the x and y coordinates:
|
||||||
x = (3 * ax * t + 2 * bx) * t + cx,
|
x = (3 * ax * t + 2 * bx) * t + cx;
|
||||||
y = (3 * ay * t + 2 * by) * t + cy;
|
y = (3 * ay * t + 2 * by) * t + cy;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@ var Curve = this.Curve = Base.extend({
|
||||||
var dx = (ax * t + bx) * t + cx,
|
var dx = (ax * t + bx) * t + cx,
|
||||||
dy = (ay * t + by) * t + cy;
|
dy = (ay * t + by) * t + cy;
|
||||||
return Math.sqrt(dx * dx + dy * dy);
|
return Math.sqrt(dx * dx + dy * dy);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Amount of integral evaluations for the interval 0 <= a < b <= 1
|
// Amount of integral evaluations for the interval 0 <= a < b <= 1
|
||||||
|
|
|
@ -139,6 +139,6 @@ CurveLocation = Base.extend({
|
||||||
var parameter = this.getParameter();
|
var parameter = this.getParameter();
|
||||||
if (parameter != null)
|
if (parameter != null)
|
||||||
parts.push('parameter: ' + parameter);
|
parts.push('parameter: ' + parameter);
|
||||||
return '{ ' + parts.join(', ') + ' }'
|
return '{ ' + parts.join(', ') + ' }';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -59,7 +59,7 @@ var Key = new function() {
|
||||||
event.returnValue = false;
|
event.returnValue = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
var res = paper.tool[toolHandler](keyEvent);
|
var res = paper.tool[toolHandler](keyEvent);
|
||||||
// TODO: Port to Scriptographer:
|
// TODO: Port to Scriptographer:
|
||||||
// When the handler function returns false, prevent the
|
// When the handler function returns false, prevent the
|
||||||
|
|
Loading…
Reference in a new issue