mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-03-13 16:33:28 -04:00
Remove all create() constructors for basic types since new constructors are now faster.
Woop!
This commit is contained in:
parent
0f74c01f75
commit
cd7db56249
18 changed files with 74 additions and 110 deletions
|
@ -52,7 +52,7 @@ var Line = Base.extend(/** @lends Line# */{
|
|||
* @type Point
|
||||
*/
|
||||
getPoint: function() {
|
||||
return Point.create(this._px, this._py);
|
||||
return new Point(this._px, this._py);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -62,7 +62,7 @@ var Line = Base.extend(/** @lends Line# */{
|
|||
* @type Point
|
||||
*/
|
||||
getVector: function() {
|
||||
return Point.create(this._vx, this._vy);
|
||||
return new Point(this._vx, this._vy);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -121,7 +121,7 @@ var Line = Base.extend(/** @lends Line# */{
|
|||
// to extend beyond the definition points.
|
||||
if ((isInfinite || 0 <= ta && ta <= 1)
|
||||
&& (isInfinite || 0 <= tb && tb <= 1))
|
||||
return Point.create(
|
||||
return new Point(
|
||||
apx + ta * avx,
|
||||
apy + ta * avy);
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ var Matrix = Base.extend(/** @lends Matrix# */{
|
|||
* @return {Matrix} A copy of this transform.
|
||||
*/
|
||||
clone: function() {
|
||||
return Matrix.create(this._a, this._c, this._b, this._d,
|
||||
return new Matrix(this._a, this._c, this._b, this._d,
|
||||
this._tx, this._ty);
|
||||
},
|
||||
|
||||
|
@ -516,7 +516,7 @@ var Matrix = Base.extend(/** @lends Matrix# */{
|
|||
|
||||
return {
|
||||
translation: this.getTranslation(),
|
||||
scaling: Point.create(scaleX, scaleY),
|
||||
scaling: new Point(scaleX, scaleY),
|
||||
rotation: -Math.atan2(b, a) * 180 / Math.PI,
|
||||
shearing: shear
|
||||
};
|
||||
|
@ -583,7 +583,7 @@ var Matrix = Base.extend(/** @lends Matrix# */{
|
|||
*/
|
||||
getTranslation: function() {
|
||||
// No decomposition is required to extract translation, so treat this
|
||||
return Point.create(this._tx, this._ty);
|
||||
return new Point(this._tx, this._ty);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -618,7 +618,7 @@ var Matrix = Base.extend(/** @lends Matrix# */{
|
|||
*/
|
||||
inverted: function() {
|
||||
var det = this._getDeterminant();
|
||||
return det && Matrix.create(
|
||||
return det && new Matrix(
|
||||
this._d / det,
|
||||
-this._c / det,
|
||||
-this._b / det,
|
||||
|
@ -628,7 +628,7 @@ var Matrix = Base.extend(/** @lends Matrix# */{
|
|||
},
|
||||
|
||||
shiftless: function() {
|
||||
return Matrix.create(this._a, this._c, this._b, this._d, 0, 0);
|
||||
return new Matrix(this._a, this._c, this._b, this._d, 0, 0);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -638,13 +638,6 @@ var Matrix = Base.extend(/** @lends Matrix# */{
|
|||
*/
|
||||
applyToContext: function(ctx) {
|
||||
ctx.transform(this._a, this._c, this._b, this._d, this._tx, this._ty);
|
||||
},
|
||||
|
||||
statics: /** @lends Matrix */{
|
||||
// See Point.create()
|
||||
create: function(a, c, b, d, tx, ty) {
|
||||
return Base.create(Matrix).set(a, c, b, d, tx, ty);
|
||||
}
|
||||
}
|
||||
}, new function() {
|
||||
return Base.each({
|
||||
|
|
|
@ -216,7 +216,7 @@ var Point = Base.extend(/** @lends Point# */{
|
|||
* @returns {Point} the cloned point
|
||||
*/
|
||||
clone: function() {
|
||||
return Point.create(this.x, this.y);
|
||||
return new Point(this.x, this.y);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -268,7 +268,7 @@ var Point = Base.extend(/** @lends Point# */{
|
|||
*/
|
||||
add: function(point) {
|
||||
point = Point.read(arguments);
|
||||
return Point.create(this.x + point.x, this.y + point.y);
|
||||
return new Point(this.x + point.x, this.y + point.y);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -304,7 +304,7 @@ var Point = Base.extend(/** @lends Point# */{
|
|||
*/
|
||||
subtract: function(point) {
|
||||
point = Point.read(arguments);
|
||||
return Point.create(this.x - point.x, this.y - point.y);
|
||||
return new Point(this.x - point.x, this.y - point.y);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -340,7 +340,7 @@ var Point = Base.extend(/** @lends Point# */{
|
|||
*/
|
||||
multiply: function(point) {
|
||||
point = Point.read(arguments);
|
||||
return Point.create(this.x * point.x, this.y * point.y);
|
||||
return new Point(this.x * point.x, this.y * point.y);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -376,7 +376,7 @@ var Point = Base.extend(/** @lends Point# */{
|
|||
*/
|
||||
divide: function(point) {
|
||||
point = Point.read(arguments);
|
||||
return Point.create(this.x / point.x, this.y / point.y);
|
||||
return new Point(this.x / point.x, this.y / point.y);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -409,11 +409,11 @@ var Point = Base.extend(/** @lends Point# */{
|
|||
*/
|
||||
modulo: function(point) {
|
||||
point = Point.read(arguments);
|
||||
return Point.create(this.x % point.x, this.y % point.y);
|
||||
return new Point(this.x % point.x, this.y % point.y);
|
||||
},
|
||||
|
||||
negate: function() {
|
||||
return Point.create(-this.x, -this.y);
|
||||
return new Point(-this.x, -this.y);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -500,7 +500,7 @@ var Point = Base.extend(/** @lends Point# */{
|
|||
length = 1;
|
||||
var current = this.getLength(),
|
||||
scale = current != 0 ? length / current : 0,
|
||||
point = Point.create(this.x * scale, this.y * scale);
|
||||
point = new Point(this.x * scale, this.y * scale);
|
||||
// Preserve angle.
|
||||
point._angle = this._angle;
|
||||
return point;
|
||||
|
@ -649,7 +649,7 @@ var Point = Base.extend(/** @lends Point# */{
|
|||
var point = center ? this.subtract(center) : this,
|
||||
s = Math.sin(angle),
|
||||
c = Math.cos(angle);
|
||||
point = Point.create(
|
||||
point = new Point(
|
||||
point.x * c - point.y * s,
|
||||
point.y * c + point.x * s
|
||||
);
|
||||
|
@ -753,10 +753,10 @@ var Point = Base.extend(/** @lends Point# */{
|
|||
project: function(point) {
|
||||
point = Point.read(arguments);
|
||||
if (point.isZero()) {
|
||||
return Point.create(0, 0);
|
||||
return new Point(0, 0);
|
||||
} else {
|
||||
var scale = this.dot(point) / point.dot(point);
|
||||
return Point.create(
|
||||
return new Point(
|
||||
point.x * scale,
|
||||
point.y * scale
|
||||
);
|
||||
|
@ -774,23 +774,6 @@ var Point = Base.extend(/** @lends Point# */{
|
|||
*/
|
||||
|
||||
statics: /** @lends Point */{
|
||||
/**
|
||||
* Provide a faster creator for Points out of two coordinates that
|
||||
* does not rely on Point#initialize at all. This speeds up all math
|
||||
* operations a lot.
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
create: function(x, y) {
|
||||
// Don't use the shorter form as we want absolute maximum
|
||||
// performance here:
|
||||
// return Base.create(Point).set(x, y);
|
||||
var point = Base.create(Point);
|
||||
point.x = x;
|
||||
point.y = y;
|
||||
return point;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a new point object with the smallest {@link #x} and
|
||||
* {@link #y} of the supplied points.
|
||||
|
@ -809,7 +792,7 @@ var Point = Base.extend(/** @lends Point# */{
|
|||
min: function(point1, point2) {
|
||||
var _point1 = Point.read(arguments);
|
||||
_point2 = Point.read(arguments);
|
||||
return Point.create(
|
||||
return new Point(
|
||||
Math.min(_point1.x, _point2.x),
|
||||
Math.min(_point1.y, _point2.y)
|
||||
);
|
||||
|
@ -833,7 +816,7 @@ var Point = Base.extend(/** @lends Point# */{
|
|||
max: function(point1, point2) {
|
||||
var _point1 = Point.read(arguments);
|
||||
_point2 = Point.read(arguments);
|
||||
return Point.create(
|
||||
return new Point(
|
||||
Math.max(_point1.x, _point2.x),
|
||||
Math.max(_point1.y, _point2.y)
|
||||
);
|
||||
|
@ -854,7 +837,7 @@ var Point = Base.extend(/** @lends Point# */{
|
|||
* var point = maxPoint * randomPoint;
|
||||
*/
|
||||
random: function() {
|
||||
return Point.create(Math.random(), Math.random());
|
||||
return new Point(Math.random(), Math.random());
|
||||
}
|
||||
}
|
||||
}, new function() { // Scope for injecting round, ceil, floor, abs:
|
||||
|
@ -921,7 +904,7 @@ var Point = Base.extend(/** @lends Point# */{
|
|||
return Base.each(['round', 'ceil', 'floor', 'abs'], function(name) {
|
||||
var op = Math[name];
|
||||
this[name] = function() {
|
||||
return Point.create(op(this.x), op(this.y));
|
||||
return new Point(op(this.x), op(this.y));
|
||||
};
|
||||
}, {});
|
||||
});
|
||||
|
@ -969,7 +952,7 @@ var LinkedPoint = Point.extend({
|
|||
// through an optional parameter that can be passed to the getters.
|
||||
// See e.g. Rectangle#getPoint(true).
|
||||
if (dontLink)
|
||||
return Point.create(x, y);
|
||||
return new Point(x, y);
|
||||
var point = Base.create(LinkedPoint);
|
||||
point._x = x;
|
||||
point._y = y;
|
||||
|
|
|
@ -190,7 +190,7 @@ var Rectangle = Base.extend(/** @lends Rectangle# */{
|
|||
* Returns a copy of the rectangle.
|
||||
*/
|
||||
clone: function() {
|
||||
return Rectangle.create(this.x, this.y, this.width, this.height);
|
||||
return new Rectangle(this.x, this.y, this.width, this.height);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -651,7 +651,7 @@ var Rectangle = Base.extend(/** @lends Rectangle# */{
|
|||
y1 = Math.max(this.y, rect.y),
|
||||
x2 = Math.min(this.x + this.width, rect.x + rect.width),
|
||||
y2 = Math.min(this.y + this.height, rect.y + rect.height);
|
||||
return Rectangle.create(x1, y1, x2 - x1, y2 - y1);
|
||||
return new Rectangle(x1, y1, x2 - x1, y2 - y1);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -668,7 +668,7 @@ var Rectangle = Base.extend(/** @lends Rectangle# */{
|
|||
y1 = Math.min(this.y, rect.y),
|
||||
x2 = Math.max(this.x + this.width, rect.x + rect.width),
|
||||
y2 = Math.max(this.y + this.height, rect.y + rect.height);
|
||||
return Rectangle.create(x1, y1, x2 - x1, y2 - y1);
|
||||
return new Rectangle(x1, y1, x2 - x1, y2 - y1);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -691,7 +691,7 @@ var Rectangle = Base.extend(/** @lends Rectangle# */{
|
|||
y1 = Math.min(this.y, point.y),
|
||||
x2 = Math.max(this.x + this.width, point.x),
|
||||
y2 = Math.max(this.y + this.height, point.y);
|
||||
return Rectangle.create(x1, y1, x2 - x1, y2 - y1);
|
||||
return new Rectangle(x1, y1, x2 - x1, y2 - y1);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -715,7 +715,7 @@ var Rectangle = Base.extend(/** @lends Rectangle# */{
|
|||
expand: function(hor, ver) {
|
||||
if (ver === undefined)
|
||||
ver = hor;
|
||||
return Rectangle.create(this.x - hor / 2, this.y - ver / 2,
|
||||
return new Rectangle(this.x - hor / 2, this.y - ver / 2,
|
||||
this.width + hor, this.height + ver);
|
||||
},
|
||||
|
||||
|
@ -739,13 +739,6 @@ var Rectangle = Base.extend(/** @lends Rectangle# */{
|
|||
scale: function(hor, ver) {
|
||||
return this.expand(this.width * hor - this.width,
|
||||
this.height * (ver === undefined ? hor : ver) - this.height);
|
||||
},
|
||||
|
||||
statics: {
|
||||
// See Point.create()
|
||||
create: function(x, y, width, height) {
|
||||
return Base.create(Rectangle).set(x, y, width, height);
|
||||
}
|
||||
}
|
||||
}, new function() {
|
||||
return Base.each([
|
||||
|
|
|
@ -163,7 +163,7 @@ var Size = Base.extend(/** @lends Size# */{
|
|||
* Returns a copy of the size.
|
||||
*/
|
||||
clone: function() {
|
||||
return Size.create(this.width, this.height);
|
||||
return new Size(this.width, this.height);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -213,7 +213,7 @@ var Size = Base.extend(/** @lends Size# */{
|
|||
*/
|
||||
add: function(size) {
|
||||
size = Size.read(arguments);
|
||||
return Size.create(this.width + size.width, this.height + size.height);
|
||||
return new Size(this.width + size.width, this.height + size.height);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -248,7 +248,7 @@ var Size = Base.extend(/** @lends Size# */{
|
|||
*/
|
||||
subtract: function(size) {
|
||||
size = Size.read(arguments);
|
||||
return Size.create(this.width - size.width, this.height - size.height);
|
||||
return new Size(this.width - size.width, this.height - size.height);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -282,7 +282,7 @@ var Size = Base.extend(/** @lends Size# */{
|
|||
*/
|
||||
multiply: function(size) {
|
||||
size = Size.read(arguments);
|
||||
return Size.create(this.width * size.width, this.height * size.height);
|
||||
return new Size(this.width * size.width, this.height * size.height);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -316,7 +316,7 @@ var Size = Base.extend(/** @lends Size# */{
|
|||
*/
|
||||
divide: function(size) {
|
||||
size = Size.read(arguments);
|
||||
return Size.create(this.width / size.width, this.height / size.height);
|
||||
return new Size(this.width / size.width, this.height / size.height);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -349,11 +349,11 @@ var Size = Base.extend(/** @lends Size# */{
|
|||
*/
|
||||
modulo: function(size) {
|
||||
size = Size.read(arguments);
|
||||
return Size.create(this.width % size.width, this.height % size.height);
|
||||
return new Size(this.width % size.width, this.height % size.height);
|
||||
},
|
||||
|
||||
negate: function() {
|
||||
return Size.create(-this.width, -this.height);
|
||||
return new Size(-this.width, -this.height);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -376,11 +376,6 @@ var Size = Base.extend(/** @lends Size# */{
|
|||
},
|
||||
|
||||
statics: /** @lends Size */{
|
||||
// See Point.create()
|
||||
create: function(width, height) {
|
||||
return Base.create(Size).set(width, height);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a new size object with the smallest {@link #width} and
|
||||
* {@link #height} of the supplied sizes.
|
||||
|
@ -397,7 +392,7 @@ var Size = Base.extend(/** @lends Size# */{
|
|||
* console.log(minSize); // {width: 10, height: 5}
|
||||
*/
|
||||
min: function(size1, size2) {
|
||||
return Size.create(
|
||||
return new Size(
|
||||
Math.min(size1.width, size2.width),
|
||||
Math.min(size1.height, size2.height));
|
||||
},
|
||||
|
@ -418,7 +413,7 @@ var Size = Base.extend(/** @lends Size# */{
|
|||
* console.log(maxSize); // {width: 200, height: 100}
|
||||
*/
|
||||
max: function(size1, size2) {
|
||||
return Size.create(
|
||||
return new Size(
|
||||
Math.max(size1.width, size2.width),
|
||||
Math.max(size1.height, size2.height));
|
||||
},
|
||||
|
@ -436,7 +431,7 @@ var Size = Base.extend(/** @lends Size# */{
|
|||
* var size = maxSize * randomSize;
|
||||
*/
|
||||
random: function() {
|
||||
return Size.create(Math.random(), Math.random());
|
||||
return new Size(Math.random(), Math.random());
|
||||
}
|
||||
}
|
||||
}, new function() { // Scope for injecting round, ceil, floor, abs:
|
||||
|
@ -504,7 +499,7 @@ var Size = Base.extend(/** @lends Size# */{
|
|||
return Base.each(['round', 'ceil', 'floor', 'abs'], function(name) {
|
||||
var op = Math[name];
|
||||
this[name] = function() {
|
||||
return Size.create(op(this.width), op(this.height));
|
||||
return new Size(op(this.width), op(this.height));
|
||||
};
|
||||
}, {});
|
||||
});
|
||||
|
@ -550,7 +545,7 @@ var LinkedSize = Size.extend({
|
|||
create: function(owner, setter, width, height, dontLink) {
|
||||
// See LinkedPoint.create() for an explanation about dontLink.
|
||||
if (dontLink)
|
||||
return Size.create(width, height);
|
||||
return new Size(width, height);
|
||||
var size = Base.create(LinkedSize);
|
||||
size._width = width;
|
||||
size._height = height;
|
||||
|
|
|
@ -16,7 +16,7 @@ var CanvasProvider = {
|
|||
canvases: [],
|
||||
|
||||
getCanvas: function(width, height) {
|
||||
var size = height === undefined ? width : Size.create(width, height);
|
||||
var size = height === undefined ? width : new Size(width, height);
|
||||
if (this.canvases.length) {
|
||||
var canvas = this.canvases.pop();
|
||||
// If they are not the same size, we don't need to clear them
|
||||
|
|
|
@ -158,7 +158,7 @@ var DomElement = new function() {
|
|||
var doc = el.ownerDocument,
|
||||
view = doc.defaultView,
|
||||
html = doc.documentElement;
|
||||
return Rectangle.create(0, 0,
|
||||
return new Rectangle(0, 0,
|
||||
view.innerWidth || html.clientWidth,
|
||||
view.innerHeight || html.clientHeight
|
||||
);
|
||||
|
|
|
@ -49,7 +49,7 @@ var DomEvent = {
|
|||
? event.targetTouches[0]
|
||||
: event.changedTouches[0]
|
||||
: event;
|
||||
return Point.create(
|
||||
return new Point(
|
||||
pos.pageX || pos.clientX + document.documentElement.scrollLeft,
|
||||
pos.pageY || pos.clientY + document.documentElement.scrollTop
|
||||
);
|
||||
|
|
|
@ -882,7 +882,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
|||
}
|
||||
}
|
||||
return isFinite(x1)
|
||||
? Rectangle.create(x1, y1, x2 - x1, y2 - y1)
|
||||
? new Rectangle(x1, y1, x2 - x1, y2 - y1)
|
||||
: new Rectangle();
|
||||
},
|
||||
|
||||
|
@ -2340,7 +2340,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
|||
? rectangle.width / bounds.width
|
||||
: rectangle.height / bounds.height,
|
||||
newBounds = new Rectangle(new Point(),
|
||||
Size.create(bounds.width * scale, bounds.height * scale));
|
||||
new Size(bounds.width * scale, bounds.height * scale));
|
||||
newBounds.setCenter(rectangle.getCenter());
|
||||
this.setBounds(newBounds);
|
||||
},
|
||||
|
@ -2885,7 +2885,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
|||
// so we draw onto it, instead of the parentCtx
|
||||
parentCtx = ctx;
|
||||
ctx = CanvasProvider.getContext(
|
||||
bounds.getSize().ceil().add(Size.create(1, 1)));
|
||||
bounds.getSize().ceil().add(new Size(1, 1)));
|
||||
}
|
||||
ctx.save();
|
||||
// Translate the context so the topLeft of the item is at (0, 0)
|
||||
|
|
|
@ -163,7 +163,7 @@ var Raster = Item.extend(/** @lends Raster# */{
|
|||
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);
|
||||
return Size.create(
|
||||
return new Size(
|
||||
72 / u.getLength(),
|
||||
72 / v.getLength()
|
||||
);
|
||||
|
@ -217,7 +217,7 @@ var Raster = Item.extend(/** @lends Raster# */{
|
|||
if (this._canvas)
|
||||
CanvasProvider.release(this._canvas);
|
||||
this._canvas = canvas;
|
||||
this._size = Size.create(canvas.width, canvas.height);
|
||||
this._size = new Size(canvas.width, canvas.height);
|
||||
this._image = null;
|
||||
this._context = null;
|
||||
this._changed(/*#=*/ Change.GEOMETRY | /*#=*/ Change.PIXELS);
|
||||
|
@ -238,9 +238,9 @@ var Raster = Item.extend(/** @lends Raster# */{
|
|||
CanvasProvider.release(this._canvas);
|
||||
this._image = image;
|
||||
/*#*/ if (options.browser) {
|
||||
this._size = Size.create(image.naturalWidth, image.naturalHeight);
|
||||
this._size = new Size(image.naturalWidth, image.naturalHeight);
|
||||
/*#*/ } else if (options.server) {
|
||||
this._size = Size.create(image.width, image.height);
|
||||
this._size = new Size(image.width, image.height);
|
||||
/*#*/ } // options.server
|
||||
this._canvas = null;
|
||||
this._context = null;
|
||||
|
@ -374,7 +374,7 @@ var Raster = Item.extend(/** @lends Raster# */{
|
|||
bounds = new Rectangle(object);
|
||||
} else if (object.x) {
|
||||
// Create a rectangle of 1px size around the specified coordinates
|
||||
bounds = Rectangle.create(object.x - 0.5, object.y - 0.5, 1, 1);
|
||||
bounds = new Rectangle(object.x - 0.5, object.y - 0.5, 1, 1);
|
||||
}
|
||||
// Use a sample size of max 32 x 32 pixels, into which the path is
|
||||
// scaled as a clipping path, and then the actual image is drawn in and
|
||||
|
|
|
@ -243,7 +243,7 @@ var Curve = Base.extend(/** @lends Curve# */{
|
|||
var coords = this.getValues(),
|
||||
points = [];
|
||||
for (var i = 0; i < 8; i += 2)
|
||||
points.push(Point.create(coords[i], coords[i + 1]));
|
||||
points.push(new Point(coords[i], coords[i + 1]));
|
||||
return points;
|
||||
},
|
||||
|
||||
|
@ -408,9 +408,9 @@ var Curve = Base.extend(/** @lends Curve# */{
|
|||
|
||||
// Create the new segment, convert absolute -> relative:
|
||||
var x = left[6], y = left[7],
|
||||
segment = new Segment(Point.create(x, y),
|
||||
!isLinear && Point.create(left[4] - x, left[5] - y),
|
||||
!isLinear && Point.create(right[2] - x, right[3] - y));
|
||||
segment = new Segment(new Point(x, y),
|
||||
!isLinear && new Point(left[4] - x, left[5] - y),
|
||||
!isLinear && new Point(right[2] - x, right[3] - y));
|
||||
|
||||
// Insert it in the segments list, if needed:
|
||||
if (this._path) {
|
||||
|
@ -662,7 +662,7 @@ statics: {
|
|||
for (var i = 0; i < 2; i++)
|
||||
Curve._addBounds(v[i], v[i + 2], v[i + 4], v[i + 6],
|
||||
i, 0, min, max, roots);
|
||||
return Rectangle.create(min[0], min[1], max[0] - min[0], max[1] - min[1]);
|
||||
return new Rectangle(min[0], min[1], max[0] - min[0], max[1] - min[1]);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -274,7 +274,7 @@ Path.inject({ statics: new function() {
|
|||
var center = Point.readNamed(arguments, 'center'),
|
||||
radius = Base.readNamed(arguments, 'radius');
|
||||
return createEllipse(new Rectangle(center.subtract(radius),
|
||||
Size.create(radius * 2, radius * 2)))
|
||||
new Size(radius * 2, radius * 2)))
|
||||
.set(Base.getNamed(arguments));
|
||||
},
|
||||
|
||||
|
|
|
@ -1981,13 +1981,13 @@ var Path = PathItem.extend(/** @lends Path# */{
|
|||
segment.setHandleIn(handleIn.subtract(segment._point));
|
||||
if (i < n) {
|
||||
segment.setHandleOut(
|
||||
Point.create(x[i], y[i]).subtract(segment._point));
|
||||
new Point(x[i], y[i]).subtract(segment._point));
|
||||
if (i < n - 1)
|
||||
handleIn = Point.create(
|
||||
handleIn = new Point(
|
||||
2 * knots[i + 1]._x - x[i + 1],
|
||||
2 * knots[i + 1]._y - y[i + 1]);
|
||||
else
|
||||
handleIn = Point.create(
|
||||
handleIn = new Point(
|
||||
(knots[n]._x + x[n - 1]) / 2,
|
||||
(knots[n]._y + y[n - 1]) / 2);
|
||||
}
|
||||
|
@ -2282,7 +2282,7 @@ statics: {
|
|||
processSegment(segments[i]);
|
||||
if (closed)
|
||||
processSegment(first);
|
||||
return Rectangle.create(min[0], min[1], max[0] - min[0], max[1] - min[1]);
|
||||
return new Rectangle(min[0], min[1], max[0] - min[0], max[1] - min[1]);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -2304,8 +2304,8 @@ statics: {
|
|||
// Get rotated hor and ver vectors, and determine rotation angle
|
||||
// and elipse values from them:
|
||||
var mx = matrix.shiftless(),
|
||||
hor = mx.transform(Point.create(radius, 0)),
|
||||
ver = mx.transform(Point.create(0, radius)),
|
||||
hor = mx.transform(new Point(radius, 0)),
|
||||
ver = mx.transform(new Point(0, radius)),
|
||||
phi = hor.getAngleInRadians(),
|
||||
a = hor.getLength(),
|
||||
b = ver.getLength();
|
||||
|
@ -2388,9 +2388,9 @@ statics: {
|
|||
normal2 = curve2.getNormalAt(0, true).normalize(miterRadius),
|
||||
// Intersect the two lines
|
||||
line1 = new Line(point.add(normal1),
|
||||
Point.create(-normal1.y, normal1.x), true),
|
||||
new Point(-normal1.y, normal1.x), true),
|
||||
line2 = new Line(point.add(normal2),
|
||||
Point.create(-normal2.y, normal2.x), true),
|
||||
new Point(-normal2.y, normal2.x), true),
|
||||
corner = line1.intersect(line2, true);
|
||||
// Now measure the distance from the segment to the
|
||||
// intersection, which his half of the miter distance
|
||||
|
@ -2465,7 +2465,7 @@ statics: {
|
|||
if (yx > y2) y2 = yx;
|
||||
}
|
||||
}
|
||||
return Rectangle.create(x1, y1, x2 - x1, y2 - y1);
|
||||
return new Rectangle(x1, y1, x2 - x1, y2 - y1);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -158,7 +158,7 @@ PathItem.inject(new function() {
|
|||
if (segment.getPrevious()._invalid)
|
||||
segment.setHandleIn(intersection
|
||||
? intersection._handleIn
|
||||
: Point.create(0, 0));
|
||||
: new Point(0, 0));
|
||||
do {
|
||||
segment._visited = true;
|
||||
if (segment._invalid && segment._intersection) {
|
||||
|
|
|
@ -44,14 +44,14 @@ new function() {
|
|||
x = getValue(node, x, false, allowNull);
|
||||
y = getValue(node, y, false, allowNull);
|
||||
return allowNull && x == null && y == null ? null
|
||||
: Point.create(x || 0, y || 0);
|
||||
: new Point(x || 0, y || 0);
|
||||
}
|
||||
|
||||
function getSize(node, w, h, allowNull) {
|
||||
w = getValue(node, w, false, allowNull);
|
||||
h = getValue(node, h, false, allowNull);
|
||||
return allowNull && w == null && h == null ? null
|
||||
: Size.create(w || 0, h || 0);
|
||||
: new Size(w || 0, h || 0);
|
||||
}
|
||||
|
||||
// Converts a string attribute value to the specified type
|
||||
|
|
|
@ -110,7 +110,7 @@ var PointText = TextItem.extend(/** @lends PointText# */{
|
|||
x -= width / (justification === 'center' ? 2: 1);
|
||||
// Until we don't have baseline measuring, assume leading / 4 as a
|
||||
// rough guess:
|
||||
var bounds = Rectangle.create(x,
|
||||
var bounds = new Rectangle(x,
|
||||
count ? leading / 4 + (count - 1) * leading : 0,
|
||||
width, -count * leading);
|
||||
return matrix ? matrix._transformBounds(bounds, bounds) : bounds;
|
||||
|
|
|
@ -28,7 +28,7 @@ var CanvasView = View.extend(/** @lends CanvasView# */{
|
|||
// 2nd argument onwards could be view size, otherwise use default:
|
||||
var size = Size.read(arguments, 1);
|
||||
if (size.isZero())
|
||||
size = Size.create(1024, 768);
|
||||
size = new Size(1024, 768);
|
||||
canvas = CanvasProvider.getCanvas(size);
|
||||
}
|
||||
this._context = canvas.getContext('2d');
|
||||
|
|
|
@ -60,7 +60,7 @@ var View = Base.extend(Callback, /** @lends View# */{
|
|||
// If the element is invisible, we cannot directly access
|
||||
// element.width / height, because they would appear 0.
|
||||
// Reading the attributes still works.
|
||||
size = Size.create(parseInt(element.getAttribute('width'), 10),
|
||||
size = new Size(parseInt(element.getAttribute('width'), 10),
|
||||
parseInt(element.getAttribute('height'), 10));
|
||||
// If no size was specified on the canvas, read it from CSS
|
||||
if (size.isNaN())
|
||||
|
@ -86,7 +86,7 @@ var View = Base.extend(Callback, /** @lends View# */{
|
|||
/*#*/ } else if (options.server) {
|
||||
// Generate an id for this view
|
||||
this._id = 'view-' + View._id++;
|
||||
size = Size.create(element.width, element.height);
|
||||
size = new Size(element.width, element.height);
|
||||
/*#*/ } // options.server
|
||||
// Keep track of views internally
|
||||
View._views.push(this);
|
||||
|
|
Loading…
Reference in a new issue