Various small code cleanups.

This commit is contained in:
Jonathan Puckey 2011-05-02 12:23:42 +02:00
parent b0282b9bd4
commit 41120cf4d9
8 changed files with 13 additions and 13 deletions

View file

@ -39,7 +39,7 @@ var Line = this.Line = Base.extend({
// Epsilon tolerance
if (Math.abs(cross) <= 10e-6)
return null;
var v = line.point.subtract(this.point)
var v = line.point.subtract(this.point),
t1 = v.cross(line.vector) / cross,
t2 = v.cross(this.vector) / cross;
// Check the ranges of t parameters if the line is not allowed to

View file

@ -310,7 +310,7 @@ var LinkedRectangle = Rectangle.extend({
var internal = '_' + key;
this['get' + part] = function() {
return this[internal];
}
};
this['set' + part] = function(value) {
this[internal] = value;
@ -318,7 +318,7 @@ var LinkedRectangle = Rectangle.extend({
// _dontNotify, as it will notify itself
if (!this._dontNotify)
this._owner[this._set](this);
}
};
}, Base.each(['Point', 'Size', 'Center',
'Left', 'Top', 'Right', 'Bottom', 'CenterX', 'CenterY',
'TopLeft', 'TopRight', 'BottomLeft', 'BottomRight',
@ -334,7 +334,7 @@ var LinkedRectangle = Rectangle.extend({
delete this._dontNotify;
this._owner[this._set](this);
return this;
}
};
}, { beans: true })
);
});

View file

@ -20,7 +20,7 @@ var Gradient = this.Gradient = Base.extend({
// TODO: should type here be called 'radial' and have it
// receive a boolean value?
initialize: function(stops, type) {
if(!stops) {
if (!stops) {
stops = [new GradientStop('white', 0),
new GradientStop('black', 1)];
}
@ -36,12 +36,12 @@ var Gradient = this.Gradient = Base.extend({
if (stops.length < 2)
throw new Error(
'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++) {
var rampPoint;
var stop = stops[i];
// If it is an array, the second argument is the rampPoint:
if(stop.length) {
if (stop.length) {
rampPoint = stop[1];
stop = stop[0];
} else {

View file

@ -66,7 +66,7 @@ var Layer = this.Layer = Group.extend({
} else {
return this.base(item);
}
}
};
}
return {

View file

@ -67,7 +67,7 @@ var Raster = this.Raster = Item.extend({
* Pixels per inch of the raster at it's current size.
*/
getPpi: function() {
var matrix = this.matrix;
var matrix = this.matrix,
orig = new Point(0, 0).transform(matrix),
u = new Point(1, 0).transform(matrix).subtract(orig),
v = new Point(0, 1).transform(matrix).subtract(orig);

View file

@ -278,7 +278,7 @@ var Curve = this.Curve = Base.extend({
case 2: // normal
// Simply use the derivation of the bezier function for both
// 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;
break;
}
@ -304,7 +304,7 @@ var Curve = this.Curve = Base.extend({
var dx = (ax * t + bx) * t + cx,
dy = (ay * t + by) * t + cy;
return Math.sqrt(dx * dx + dy * dy);
}
};
}
// Amount of integral evaluations for the interval 0 <= a < b <= 1

View file

@ -139,6 +139,6 @@ CurveLocation = Base.extend({
var parameter = this.getParameter();
if (parameter != null)
parts.push('parameter: ' + parameter);
return '{ ' + parts.join(', ') + ' }'
return '{ ' + parts.join(', ') + ' }';
}
});

View file

@ -59,7 +59,7 @@ var Key = new function() {
event.returnValue = false;
}
}
}
};
var res = paper.tool[toolHandler](keyEvent);
// TODO: Port to Scriptographer:
// When the handler function returns false, prevent the