Prebuilt module for commit c7d85b663e

This commit is contained in:
Paper.js Bot 2019-12-15 18:44:31 +00:00
parent 4ec8440517
commit ecc898999a
6 changed files with 444 additions and 342 deletions

View file

@ -9,7 +9,7 @@
*
* All rights reserved.
*
* Date: Sun Dec 15 14:34:46 2019 +0100
* Date: Sun Dec 15 19:40:40 2019 +0100
*
***
*
@ -1525,11 +1525,12 @@ var Point = Base.extend({
},
getDistance: function() {
var point = Point.read(arguments),
var args = arguments,
point = Point.read(args),
x = point.x - this.x,
y = point.y - this.y,
d = x * x + y * y,
squared = Base.read(arguments);
squared = Base.read(args);
return squared ? d : Math.sqrt(d);
},
@ -1596,8 +1597,9 @@ var Point = Base.extend({
},
isClose: function() {
var point = Point.read(arguments),
tolerance = Base.read(arguments);
var args = arguments,
point = Point.read(args),
tolerance = Base.read(args);
return this.getDistance(point) <= tolerance;
},
@ -1648,8 +1650,9 @@ var Point = Base.extend({
statics: {
min: function() {
var point1 = Point.read(arguments),
point2 = Point.read(arguments);
var args = arguments,
point1 = Point.read(args),
point2 = Point.read(args);
return new Point(
Math.min(point1.x, point2.x),
Math.min(point1.y, point2.y)
@ -1657,8 +1660,9 @@ var Point = Base.extend({
},
max: function() {
var point1 = Point.read(arguments),
point2 = Point.read(arguments);
var args = arguments,
point1 = Point.read(args),
point2 = Point.read(args);
return new Point(
Math.max(point1.x, point2.x),
Math.max(point1.y, point2.y)
@ -1905,7 +1909,8 @@ var Rectangle = Base.extend({
beans: true,
initialize: function Rectangle(arg0, arg1, arg2, arg3) {
var type = typeof arg0,
var args = arguments,
type = typeof arg0,
read;
if (type === 'number') {
this._set(arg0, arg1, arg2, arg3);
@ -1913,7 +1918,7 @@ var Rectangle = Base.extend({
} else if (type === 'undefined' || arg0 === null) {
this._set(0, 0, 0, 0);
read = arg0 === null ? 1 : 0;
} else if (arguments.length === 1) {
} else if (args.length === 1) {
if (Array.isArray(arg0)) {
this._set.apply(this, arg0);
read = 1;
@ -1923,21 +1928,20 @@ var Rectangle = Base.extend({
read = 1;
} else if (arg0.from === undefined && arg0.to === undefined) {
this._set(0, 0, 0, 0);
if (Base.readSupported(arguments, this)) {
if (Base.readSupported(args, this)) {
read = 1;
}
}
}
if (read === undefined) {
var frm = Point.readNamed(arguments, 'from'),
next = Base.peek(arguments),
var frm = Point.readNamed(args, 'from'),
next = Base.peek(args),
x = frm.x,
y = frm.y,
width,
height;
if (next && next.x !== undefined
|| Base.hasNamed(arguments, 'to')) {
var to = Point.readNamed(arguments, 'to');
if (next && next.x !== undefined || Base.hasNamed(args, 'to')) {
var to = Point.readNamed(args, 'to');
width = to.x - x;
height = to.y - y;
if (width < 0) {
@ -1949,14 +1953,14 @@ var Rectangle = Base.extend({
height = -height;
}
} else {
var size = Size.read(arguments);
var size = Size.read(args);
width = size.width;
height = size.height;
}
this._set(x, y, width, height);
read = arguments.__index;
read = args.__index;
}
var filtered = arguments.__filtered;
var filtered = args.__filtered;
if (filtered)
this.__filtered = filtered;
if (this.__read)
@ -2316,10 +2320,11 @@ var Matrix = Base.extend({
_class: 'Matrix',
initialize: function Matrix(arg, _dontNotify) {
var count = arguments.length,
var args = arguments,
count = args.length,
ok = true;
if (count >= 6) {
this._set.apply(this, arguments);
this._set.apply(this, args);
} else if (count === 1 || count === 2) {
if (arg instanceof Matrix) {
this._set(arg._a, arg._b, arg._c, arg._d, arg._tx, arg._ty,
@ -2417,8 +2422,9 @@ var Matrix = Base.extend({
},
scale: function() {
var scale = Point.read(arguments),
center = Point.read(arguments, 0, { readNull: true });
var args = arguments,
scale = Point.read(args),
center = Point.read(args, 0, { readNull: true });
if (center)
this.translate(center);
this._a *= scale.x;
@ -2455,8 +2461,9 @@ var Matrix = Base.extend({
},
shear: function() {
var shear = Point.read(arguments),
center = Point.read(arguments, 0, { readNull: true });
var args = arguments,
shear = Point.read(args),
center = Point.read(args, 0, { readNull: true });
if (center)
this.translate(center);
var a = this._a,
@ -2472,8 +2479,9 @@ var Matrix = Base.extend({
},
skew: function() {
var skew = Point.read(arguments),
center = Point.read(arguments, 0, { readNull: true }),
var args = arguments,
skew = Point.read(args),
center = Point.read(args, 0, { readNull: true }),
toRadians = Math.PI / 180,
shear = new Point(Math.tan(skew.x * toRadians),
Math.tan(skew.y * toRadians));
@ -3938,14 +3946,16 @@ new function() {
},
new function() {
function hitTest() {
var args = arguments;
return this._hitTest(
Point.read(arguments),
HitResult.getOptions(arguments));
Point.read(args),
HitResult.getOptions(args));
}
function hitTestAll() {
var point = Point.read(arguments),
options = HitResult.getOptions(arguments),
var args = arguments,
point = Point.read(args),
options = HitResult.getOptions(args),
all = [];
this._hitTest(point, new Base({ all: all }, options));
return all;
@ -4494,8 +4504,9 @@ new function() {
}, Base.each(['rotate', 'scale', 'shear', 'skew'], function(key) {
var rotate = key === 'rotate';
this[key] = function() {
var value = (rotate ? Base : Point).read(arguments),
center = Point.read(arguments, 0, { readNull: true });
var args = arguments,
value = (rotate ? Base : Point).read(args),
center = Point.read(args, 0, { readNull: true });
return this.transform(new Matrix()[key](value,
center || this.getPosition(true)));
};
@ -5274,25 +5285,28 @@ statics: new function() {
return {
Circle: function() {
var center = Point.readNamed(arguments, 'center'),
radius = Base.readNamed(arguments, 'radius');
var args = arguments,
center = Point.readNamed(args, 'center'),
radius = Base.readNamed(args, 'radius');
return createShape('circle', center, new Size(radius * 2), radius,
arguments);
args);
},
Rectangle: function() {
var rect = Rectangle.readNamed(arguments, 'rectangle'),
radius = Size.min(Size.readNamed(arguments, 'radius'),
var args = arguments,
rect = Rectangle.readNamed(args, 'rectangle'),
radius = Size.min(Size.readNamed(args, 'radius'),
rect.getSize(true).divide(2));
return createShape('rectangle', rect.getCenter(true),
rect.getSize(true), radius, arguments);
rect.getSize(true), radius, args);
},
Ellipse: function() {
var ellipse = Shape._readEllipse(arguments),
var args = arguments,
ellipse = Shape._readEllipse(args),
radius = ellipse.radius;
return createShape('ellipse', ellipse.center, radius.multiply(2),
radius, arguments);
radius, args);
},
_readEllipse: function(args) {
@ -5651,8 +5665,9 @@ var Raster = Item.extend({
},
setPixel: function() {
var point = Point.read(arguments),
color = Color.read(arguments),
var args = arguments,
point = Point.read(args),
color = Color.read(args),
components = color._convert('rgb'),
alpha = color._alpha,
ctx = this.getContext(true),
@ -8290,13 +8305,14 @@ var Path = PathItem.extend({
this._closed = false;
this._segments = [];
this._version = 0;
var segments = Array.isArray(arg)
var args = arguments,
segments = Array.isArray(arg)
? typeof arg[0] === 'object'
? arg
: arguments
: args
: arg && (arg.size === undefined && (arg.x !== undefined
|| arg.point !== undefined))
? arguments
? args
: null;
if (segments && segments.length > 0) {
this.setSegments(segments);
@ -8548,15 +8564,17 @@ var Path = PathItem.extend({
},
add: function(segment1 ) {
return arguments.length > 1 && typeof segment1 !== 'number'
? this._add(Segment.readList(arguments))
: this._add([ Segment.read(arguments) ])[0];
var args = arguments;
return args.length > 1 && typeof segment1 !== 'number'
? this._add(Segment.readList(args))
: this._add([ Segment.read(args) ])[0];
},
insert: function(index, segment1 ) {
return arguments.length > 2 && typeof segment1 !== 'number'
? this._add(Segment.readList(arguments, 1), index)
: this._add([ Segment.read(arguments, 1) ], index)[0];
var args = arguments;
return args.length > 2 && typeof segment1 !== 'number'
? this._add(Segment.readList(args, 1), index)
: this._add([ Segment.read(args, 1) ], index)[0];
},
addSegment: function() {
@ -9481,17 +9499,19 @@ new function() {
},
cubicCurveTo: function() {
var handle1 = Point.read(arguments),
handle2 = Point.read(arguments),
to = Point.read(arguments),
var args = arguments,
handle1 = Point.read(args),
handle2 = Point.read(args),
to = Point.read(args),
current = getCurrentSegment(this);
current.setHandleOut(handle1.subtract(current._point));
this._add([ new Segment(to, handle2.subtract(to)) ]);
},
quadraticCurveTo: function() {
var handle = Point.read(arguments),
to = Point.read(arguments),
var args = arguments,
handle = Point.read(args),
to = Point.read(args),
current = getCurrentSegment(this)._point;
this.cubicCurveTo(
handle.add(current.subtract(handle).multiply(1 / 3)),
@ -9501,9 +9521,10 @@ new function() {
},
curveTo: function() {
var through = Point.read(arguments),
to = Point.read(arguments),
t = Base.pick(Base.read(arguments), 0.5),
var args = arguments,
through = Point.read(args),
to = Point.read(args),
t = Base.pick(Base.read(args), 0.5),
t1 = 1 - t,
current = getCurrentSegment(this)._point,
handle = through.subtract(current.multiply(t1 * t1))
@ -9515,30 +9536,31 @@ new function() {
},
arcTo: function() {
var abs = Math.abs,
var args = arguments,
abs = Math.abs,
sqrt = Math.sqrt,
current = getCurrentSegment(this),
from = current._point,
to = Point.read(arguments),
to = Point.read(args),
through,
peek = Base.peek(arguments),
peek = Base.peek(args),
clockwise = Base.pick(peek, true),
center, extent, vector, matrix;
if (typeof clockwise === 'boolean') {
var middle = from.add(to).divide(2),
through = middle.add(middle.subtract(from).rotate(
clockwise ? -90 : 90));
} else if (Base.remain(arguments) <= 2) {
} else if (Base.remain(args) <= 2) {
through = to;
to = Point.read(arguments);
to = Point.read(args);
} else if (!from.equals(to)) {
var radius = Size.read(arguments),
var radius = Size.read(args),
isZero = Numerical.isZero;
if (isZero(radius.width) || isZero(radius.height))
return this.lineTo(to);
var rotation = Base.read(arguments),
clockwise = !!Base.read(arguments),
large = !!Base.read(arguments),
var rotation = Base.read(args),
clockwise = !!Base.read(args),
large = !!Base.read(args),
middle = from.add(to).divide(2),
pt = from.subtract(middle).rotate(-rotation),
x = pt.x,
@ -9642,37 +9664,41 @@ new function() {
},
curveBy: function() {
var through = Point.read(arguments),
to = Point.read(arguments),
parameter = Base.read(arguments),
var args = arguments,
through = Point.read(args),
to = Point.read(args),
parameter = Base.read(args),
current = getCurrentSegment(this)._point;
this.curveTo(current.add(through), current.add(to), parameter);
},
cubicCurveBy: function() {
var handle1 = Point.read(arguments),
handle2 = Point.read(arguments),
to = Point.read(arguments),
var args = arguments,
handle1 = Point.read(args),
handle2 = Point.read(args),
to = Point.read(args),
current = getCurrentSegment(this)._point;
this.cubicCurveTo(current.add(handle1), current.add(handle2),
current.add(to));
},
quadraticCurveBy: function() {
var handle = Point.read(arguments),
to = Point.read(arguments),
var args = arguments,
handle = Point.read(args),
to = Point.read(args),
current = getCurrentSegment(this)._point;
this.quadraticCurveTo(current.add(handle), current.add(to));
},
arcBy: function() {
var current = getCurrentSegment(this)._point,
point = current.add(Point.read(arguments)),
clockwise = Base.pick(Base.peek(arguments), true);
var args = arguments,
current = getCurrentSegment(this)._point,
point = current.add(Point.read(args)),
clockwise = Base.pick(Base.peek(args), true);
if (typeof clockwise === 'boolean') {
this.arcTo(point, clockwise);
} else {
this.arcTo(point, current.add(Point.read(arguments)));
this.arcTo(point, current.add(Point.read(args)));
}
},
@ -9923,21 +9949,24 @@ Path.inject({ statics: new function() {
return {
Line: function() {
var args = arguments;
return createPath([
new Segment(Point.readNamed(arguments, 'from')),
new Segment(Point.readNamed(arguments, 'to'))
], false, arguments);
new Segment(Point.readNamed(args, 'from')),
new Segment(Point.readNamed(args, 'to'))
], false, args);
},
Circle: function() {
var center = Point.readNamed(arguments, 'center'),
radius = Base.readNamed(arguments, 'radius');
return createEllipse(center, new Size(radius), arguments);
var args = arguments,
center = Point.readNamed(args, 'center'),
radius = Base.readNamed(args, 'radius');
return createEllipse(center, new Size(radius), args);
},
Rectangle: function() {
var rect = Rectangle.readNamed(arguments, 'rectangle'),
radius = Size.readNamed(arguments, 'radius', 0,
var args = arguments,
rect = Rectangle.readNamed(args, 'rectangle'),
radius = Size.readNamed(args, 'radius', 0,
{ readNull: true }),
bl = rect.getBottomLeft(true),
tl = rect.getTopLeft(true),
@ -9968,23 +9997,25 @@ Path.inject({ statics: new function() {
new Segment(br.subtract(rx, 0), [hx, 0])
];
}
return createPath(segments, true, arguments);
return createPath(segments, true, args);
},
RoundRectangle: '#Rectangle',
Ellipse: function() {
var ellipse = Shape._readEllipse(arguments);
return createEllipse(ellipse.center, ellipse.radius, arguments);
var args = arguments,
ellipse = Shape._readEllipse(args);
return createEllipse(ellipse.center, ellipse.radius, args);
},
Oval: '#Ellipse',
Arc: function() {
var from = Point.readNamed(arguments, 'from'),
through = Point.readNamed(arguments, 'through'),
to = Point.readNamed(arguments, 'to'),
props = Base.getNamed(arguments),
var args = arguments,
from = Point.readNamed(args, 'from'),
through = Point.readNamed(args, 'through'),
to = Point.readNamed(args, 'to'),
props = Base.getNamed(args),
path = new Path(props && props.insert == false
&& Item.NO_INSERT);
path.moveTo(from);
@ -9993,9 +10024,10 @@ Path.inject({ statics: new function() {
},
RegularPolygon: function() {
var center = Point.readNamed(arguments, 'center'),
sides = Base.readNamed(arguments, 'sides'),
radius = Base.readNamed(arguments, 'radius'),
var args = arguments,
center = Point.readNamed(args, 'center'),
sides = Base.readNamed(args, 'sides'),
radius = Base.readNamed(args, 'radius'),
step = 360 / sides,
three = sides % 3 === 0,
vector = new Point(0, three ? -radius : radius),
@ -10004,21 +10036,22 @@ Path.inject({ statics: new function() {
for (var i = 0; i < sides; i++)
segments[i] = new Segment(center.add(
vector.rotate((i + offset) * step)));
return createPath(segments, true, arguments);
return createPath(segments, true, args);
},
Star: function() {
var center = Point.readNamed(arguments, 'center'),
points = Base.readNamed(arguments, 'points') * 2,
radius1 = Base.readNamed(arguments, 'radius1'),
radius2 = Base.readNamed(arguments, 'radius2'),
var args = arguments,
center = Point.readNamed(args, 'center'),
points = Base.readNamed(args, 'points') * 2,
radius1 = Base.readNamed(args, 'radius1'),
radius2 = Base.readNamed(args, 'radius2'),
step = 360 / points,
vector = new Point(0, -1),
segments = new Array(points);
for (var i = 0; i < points; i++)
segments[i] = new Segment(center.add(vector.rotate(step * i)
.multiply(i % 2 ? radius2 : radius1)));
return createPath(segments, true, arguments);
return createPath(segments, true, args);
}
};
}});
@ -13016,8 +13049,9 @@ var View = Base.extend(Emitter, {
}, Base.each(['rotate', 'scale', 'shear', 'skew'], function(key) {
var rotate = key === 'rotate';
this[key] = function() {
var value = (rotate ? Base : Point).read(arguments),
center = Point.read(arguments, 0, { readNull: true });
var args = arguments,
value = (rotate ? Base : Point).read(args),
center = Point.read(args, 0, { readNull: true });
return this.transform(new Matrix()[key](value,
center || this.getCenter(true)));
};

250
dist/paper-core.js vendored
View file

@ -9,7 +9,7 @@
*
* All rights reserved.
*
* Date: Sun Dec 15 14:34:46 2019 +0100
* Date: Sun Dec 15 19:40:40 2019 +0100
*
***
*
@ -1522,11 +1522,12 @@ var Point = Base.extend({
},
getDistance: function() {
var point = Point.read(arguments),
var args = arguments,
point = Point.read(args),
x = point.x - this.x,
y = point.y - this.y,
d = x * x + y * y,
squared = Base.read(arguments);
squared = Base.read(args);
return squared ? d : Math.sqrt(d);
},
@ -1593,8 +1594,9 @@ var Point = Base.extend({
},
isClose: function() {
var point = Point.read(arguments),
tolerance = Base.read(arguments);
var args = arguments,
point = Point.read(args),
tolerance = Base.read(args);
return this.getDistance(point) <= tolerance;
},
@ -1645,8 +1647,9 @@ var Point = Base.extend({
statics: {
min: function() {
var point1 = Point.read(arguments),
point2 = Point.read(arguments);
var args = arguments,
point1 = Point.read(args),
point2 = Point.read(args);
return new Point(
Math.min(point1.x, point2.x),
Math.min(point1.y, point2.y)
@ -1654,8 +1657,9 @@ var Point = Base.extend({
},
max: function() {
var point1 = Point.read(arguments),
point2 = Point.read(arguments);
var args = arguments,
point1 = Point.read(args),
point2 = Point.read(args);
return new Point(
Math.max(point1.x, point2.x),
Math.max(point1.y, point2.y)
@ -1902,7 +1906,8 @@ var Rectangle = Base.extend({
beans: true,
initialize: function Rectangle(arg0, arg1, arg2, arg3) {
var type = typeof arg0,
var args = arguments,
type = typeof arg0,
read;
if (type === 'number') {
this._set(arg0, arg1, arg2, arg3);
@ -1910,7 +1915,7 @@ var Rectangle = Base.extend({
} else if (type === 'undefined' || arg0 === null) {
this._set(0, 0, 0, 0);
read = arg0 === null ? 1 : 0;
} else if (arguments.length === 1) {
} else if (args.length === 1) {
if (Array.isArray(arg0)) {
this._set.apply(this, arg0);
read = 1;
@ -1920,21 +1925,20 @@ var Rectangle = Base.extend({
read = 1;
} else if (arg0.from === undefined && arg0.to === undefined) {
this._set(0, 0, 0, 0);
if (Base.readSupported(arguments, this)) {
if (Base.readSupported(args, this)) {
read = 1;
}
}
}
if (read === undefined) {
var frm = Point.readNamed(arguments, 'from'),
next = Base.peek(arguments),
var frm = Point.readNamed(args, 'from'),
next = Base.peek(args),
x = frm.x,
y = frm.y,
width,
height;
if (next && next.x !== undefined
|| Base.hasNamed(arguments, 'to')) {
var to = Point.readNamed(arguments, 'to');
if (next && next.x !== undefined || Base.hasNamed(args, 'to')) {
var to = Point.readNamed(args, 'to');
width = to.x - x;
height = to.y - y;
if (width < 0) {
@ -1946,14 +1950,14 @@ var Rectangle = Base.extend({
height = -height;
}
} else {
var size = Size.read(arguments);
var size = Size.read(args);
width = size.width;
height = size.height;
}
this._set(x, y, width, height);
read = arguments.__index;
read = args.__index;
}
var filtered = arguments.__filtered;
var filtered = args.__filtered;
if (filtered)
this.__filtered = filtered;
if (this.__read)
@ -2313,10 +2317,11 @@ var Matrix = Base.extend({
_class: 'Matrix',
initialize: function Matrix(arg, _dontNotify) {
var count = arguments.length,
var args = arguments,
count = args.length,
ok = true;
if (count >= 6) {
this._set.apply(this, arguments);
this._set.apply(this, args);
} else if (count === 1 || count === 2) {
if (arg instanceof Matrix) {
this._set(arg._a, arg._b, arg._c, arg._d, arg._tx, arg._ty,
@ -2414,8 +2419,9 @@ var Matrix = Base.extend({
},
scale: function() {
var scale = Point.read(arguments),
center = Point.read(arguments, 0, { readNull: true });
var args = arguments,
scale = Point.read(args),
center = Point.read(args, 0, { readNull: true });
if (center)
this.translate(center);
this._a *= scale.x;
@ -2452,8 +2458,9 @@ var Matrix = Base.extend({
},
shear: function() {
var shear = Point.read(arguments),
center = Point.read(arguments, 0, { readNull: true });
var args = arguments,
shear = Point.read(args),
center = Point.read(args, 0, { readNull: true });
if (center)
this.translate(center);
var a = this._a,
@ -2469,8 +2476,9 @@ var Matrix = Base.extend({
},
skew: function() {
var skew = Point.read(arguments),
center = Point.read(arguments, 0, { readNull: true }),
var args = arguments,
skew = Point.read(args),
center = Point.read(args, 0, { readNull: true }),
toRadians = Math.PI / 180,
shear = new Point(Math.tan(skew.x * toRadians),
Math.tan(skew.y * toRadians));
@ -3935,14 +3943,16 @@ new function() {
},
new function() {
function hitTest() {
var args = arguments;
return this._hitTest(
Point.read(arguments),
HitResult.getOptions(arguments));
Point.read(args),
HitResult.getOptions(args));
}
function hitTestAll() {
var point = Point.read(arguments),
options = HitResult.getOptions(arguments),
var args = arguments,
point = Point.read(args),
options = HitResult.getOptions(args),
all = [];
this._hitTest(point, new Base({ all: all }, options));
return all;
@ -4491,8 +4501,9 @@ new function() {
}, Base.each(['rotate', 'scale', 'shear', 'skew'], function(key) {
var rotate = key === 'rotate';
this[key] = function() {
var value = (rotate ? Base : Point).read(arguments),
center = Point.read(arguments, 0, { readNull: true });
var args = arguments,
value = (rotate ? Base : Point).read(args),
center = Point.read(args, 0, { readNull: true });
return this.transform(new Matrix()[key](value,
center || this.getPosition(true)));
};
@ -5271,25 +5282,28 @@ statics: new function() {
return {
Circle: function() {
var center = Point.readNamed(arguments, 'center'),
radius = Base.readNamed(arguments, 'radius');
var args = arguments,
center = Point.readNamed(args, 'center'),
radius = Base.readNamed(args, 'radius');
return createShape('circle', center, new Size(radius * 2), radius,
arguments);
args);
},
Rectangle: function() {
var rect = Rectangle.readNamed(arguments, 'rectangle'),
radius = Size.min(Size.readNamed(arguments, 'radius'),
var args = arguments,
rect = Rectangle.readNamed(args, 'rectangle'),
radius = Size.min(Size.readNamed(args, 'radius'),
rect.getSize(true).divide(2));
return createShape('rectangle', rect.getCenter(true),
rect.getSize(true), radius, arguments);
rect.getSize(true), radius, args);
},
Ellipse: function() {
var ellipse = Shape._readEllipse(arguments),
var args = arguments,
ellipse = Shape._readEllipse(args),
radius = ellipse.radius;
return createShape('ellipse', ellipse.center, radius.multiply(2),
radius, arguments);
radius, args);
},
_readEllipse: function(args) {
@ -5648,8 +5662,9 @@ var Raster = Item.extend({
},
setPixel: function() {
var point = Point.read(arguments),
color = Color.read(arguments),
var args = arguments,
point = Point.read(args),
color = Color.read(args),
components = color._convert('rgb'),
alpha = color._alpha,
ctx = this.getContext(true),
@ -8287,13 +8302,14 @@ var Path = PathItem.extend({
this._closed = false;
this._segments = [];
this._version = 0;
var segments = Array.isArray(arg)
var args = arguments,
segments = Array.isArray(arg)
? typeof arg[0] === 'object'
? arg
: arguments
: args
: arg && (arg.size === undefined && (arg.x !== undefined
|| arg.point !== undefined))
? arguments
? args
: null;
if (segments && segments.length > 0) {
this.setSegments(segments);
@ -8545,15 +8561,17 @@ var Path = PathItem.extend({
},
add: function(segment1 ) {
return arguments.length > 1 && typeof segment1 !== 'number'
? this._add(Segment.readList(arguments))
: this._add([ Segment.read(arguments) ])[0];
var args = arguments;
return args.length > 1 && typeof segment1 !== 'number'
? this._add(Segment.readList(args))
: this._add([ Segment.read(args) ])[0];
},
insert: function(index, segment1 ) {
return arguments.length > 2 && typeof segment1 !== 'number'
? this._add(Segment.readList(arguments, 1), index)
: this._add([ Segment.read(arguments, 1) ], index)[0];
var args = arguments;
return args.length > 2 && typeof segment1 !== 'number'
? this._add(Segment.readList(args, 1), index)
: this._add([ Segment.read(args, 1) ], index)[0];
},
addSegment: function() {
@ -9478,17 +9496,19 @@ new function() {
},
cubicCurveTo: function() {
var handle1 = Point.read(arguments),
handle2 = Point.read(arguments),
to = Point.read(arguments),
var args = arguments,
handle1 = Point.read(args),
handle2 = Point.read(args),
to = Point.read(args),
current = getCurrentSegment(this);
current.setHandleOut(handle1.subtract(current._point));
this._add([ new Segment(to, handle2.subtract(to)) ]);
},
quadraticCurveTo: function() {
var handle = Point.read(arguments),
to = Point.read(arguments),
var args = arguments,
handle = Point.read(args),
to = Point.read(args),
current = getCurrentSegment(this)._point;
this.cubicCurveTo(
handle.add(current.subtract(handle).multiply(1 / 3)),
@ -9498,9 +9518,10 @@ new function() {
},
curveTo: function() {
var through = Point.read(arguments),
to = Point.read(arguments),
t = Base.pick(Base.read(arguments), 0.5),
var args = arguments,
through = Point.read(args),
to = Point.read(args),
t = Base.pick(Base.read(args), 0.5),
t1 = 1 - t,
current = getCurrentSegment(this)._point,
handle = through.subtract(current.multiply(t1 * t1))
@ -9512,30 +9533,31 @@ new function() {
},
arcTo: function() {
var abs = Math.abs,
var args = arguments,
abs = Math.abs,
sqrt = Math.sqrt,
current = getCurrentSegment(this),
from = current._point,
to = Point.read(arguments),
to = Point.read(args),
through,
peek = Base.peek(arguments),
peek = Base.peek(args),
clockwise = Base.pick(peek, true),
center, extent, vector, matrix;
if (typeof clockwise === 'boolean') {
var middle = from.add(to).divide(2),
through = middle.add(middle.subtract(from).rotate(
clockwise ? -90 : 90));
} else if (Base.remain(arguments) <= 2) {
} else if (Base.remain(args) <= 2) {
through = to;
to = Point.read(arguments);
to = Point.read(args);
} else if (!from.equals(to)) {
var radius = Size.read(arguments),
var radius = Size.read(args),
isZero = Numerical.isZero;
if (isZero(radius.width) || isZero(radius.height))
return this.lineTo(to);
var rotation = Base.read(arguments),
clockwise = !!Base.read(arguments),
large = !!Base.read(arguments),
var rotation = Base.read(args),
clockwise = !!Base.read(args),
large = !!Base.read(args),
middle = from.add(to).divide(2),
pt = from.subtract(middle).rotate(-rotation),
x = pt.x,
@ -9639,37 +9661,41 @@ new function() {
},
curveBy: function() {
var through = Point.read(arguments),
to = Point.read(arguments),
parameter = Base.read(arguments),
var args = arguments,
through = Point.read(args),
to = Point.read(args),
parameter = Base.read(args),
current = getCurrentSegment(this)._point;
this.curveTo(current.add(through), current.add(to), parameter);
},
cubicCurveBy: function() {
var handle1 = Point.read(arguments),
handle2 = Point.read(arguments),
to = Point.read(arguments),
var args = arguments,
handle1 = Point.read(args),
handle2 = Point.read(args),
to = Point.read(args),
current = getCurrentSegment(this)._point;
this.cubicCurveTo(current.add(handle1), current.add(handle2),
current.add(to));
},
quadraticCurveBy: function() {
var handle = Point.read(arguments),
to = Point.read(arguments),
var args = arguments,
handle = Point.read(args),
to = Point.read(args),
current = getCurrentSegment(this)._point;
this.quadraticCurveTo(current.add(handle), current.add(to));
},
arcBy: function() {
var current = getCurrentSegment(this)._point,
point = current.add(Point.read(arguments)),
clockwise = Base.pick(Base.peek(arguments), true);
var args = arguments,
current = getCurrentSegment(this)._point,
point = current.add(Point.read(args)),
clockwise = Base.pick(Base.peek(args), true);
if (typeof clockwise === 'boolean') {
this.arcTo(point, clockwise);
} else {
this.arcTo(point, current.add(Point.read(arguments)));
this.arcTo(point, current.add(Point.read(args)));
}
},
@ -9920,21 +9946,24 @@ Path.inject({ statics: new function() {
return {
Line: function() {
var args = arguments;
return createPath([
new Segment(Point.readNamed(arguments, 'from')),
new Segment(Point.readNamed(arguments, 'to'))
], false, arguments);
new Segment(Point.readNamed(args, 'from')),
new Segment(Point.readNamed(args, 'to'))
], false, args);
},
Circle: function() {
var center = Point.readNamed(arguments, 'center'),
radius = Base.readNamed(arguments, 'radius');
return createEllipse(center, new Size(radius), arguments);
var args = arguments,
center = Point.readNamed(args, 'center'),
radius = Base.readNamed(args, 'radius');
return createEllipse(center, new Size(radius), args);
},
Rectangle: function() {
var rect = Rectangle.readNamed(arguments, 'rectangle'),
radius = Size.readNamed(arguments, 'radius', 0,
var args = arguments,
rect = Rectangle.readNamed(args, 'rectangle'),
radius = Size.readNamed(args, 'radius', 0,
{ readNull: true }),
bl = rect.getBottomLeft(true),
tl = rect.getTopLeft(true),
@ -9965,23 +9994,25 @@ Path.inject({ statics: new function() {
new Segment(br.subtract(rx, 0), [hx, 0])
];
}
return createPath(segments, true, arguments);
return createPath(segments, true, args);
},
RoundRectangle: '#Rectangle',
Ellipse: function() {
var ellipse = Shape._readEllipse(arguments);
return createEllipse(ellipse.center, ellipse.radius, arguments);
var args = arguments,
ellipse = Shape._readEllipse(args);
return createEllipse(ellipse.center, ellipse.radius, args);
},
Oval: '#Ellipse',
Arc: function() {
var from = Point.readNamed(arguments, 'from'),
through = Point.readNamed(arguments, 'through'),
to = Point.readNamed(arguments, 'to'),
props = Base.getNamed(arguments),
var args = arguments,
from = Point.readNamed(args, 'from'),
through = Point.readNamed(args, 'through'),
to = Point.readNamed(args, 'to'),
props = Base.getNamed(args),
path = new Path(props && props.insert == false
&& Item.NO_INSERT);
path.moveTo(from);
@ -9990,9 +10021,10 @@ Path.inject({ statics: new function() {
},
RegularPolygon: function() {
var center = Point.readNamed(arguments, 'center'),
sides = Base.readNamed(arguments, 'sides'),
radius = Base.readNamed(arguments, 'radius'),
var args = arguments,
center = Point.readNamed(args, 'center'),
sides = Base.readNamed(args, 'sides'),
radius = Base.readNamed(args, 'radius'),
step = 360 / sides,
three = sides % 3 === 0,
vector = new Point(0, three ? -radius : radius),
@ -10001,21 +10033,22 @@ Path.inject({ statics: new function() {
for (var i = 0; i < sides; i++)
segments[i] = new Segment(center.add(
vector.rotate((i + offset) * step)));
return createPath(segments, true, arguments);
return createPath(segments, true, args);
},
Star: function() {
var center = Point.readNamed(arguments, 'center'),
points = Base.readNamed(arguments, 'points') * 2,
radius1 = Base.readNamed(arguments, 'radius1'),
radius2 = Base.readNamed(arguments, 'radius2'),
var args = arguments,
center = Point.readNamed(args, 'center'),
points = Base.readNamed(args, 'points') * 2,
radius1 = Base.readNamed(args, 'radius1'),
radius2 = Base.readNamed(args, 'radius2'),
step = 360 / points,
vector = new Point(0, -1),
segments = new Array(points);
for (var i = 0; i < points; i++)
segments[i] = new Segment(center.add(vector.rotate(step * i)
.multiply(i % 2 ? radius2 : radius1)));
return createPath(segments, true, arguments);
return createPath(segments, true, args);
}
};
}});
@ -13013,8 +13046,9 @@ var View = Base.extend(Emitter, {
}, Base.each(['rotate', 'scale', 'shear', 'skew'], function(key) {
var rotate = key === 'rotate';
this[key] = function() {
var value = (rotate ? Base : Point).read(arguments),
center = Point.read(arguments, 0, { readNull: true });
var args = arguments,
value = (rotate ? Base : Point).read(args),
center = Point.read(args, 0, { readNull: true });
return this.transform(new Matrix()[key](value,
center || this.getCenter(true)));
};

File diff suppressed because one or more lines are too long

250
dist/paper-full.js vendored
View file

@ -9,7 +9,7 @@
*
* All rights reserved.
*
* Date: Sun Dec 15 14:34:46 2019 +0100
* Date: Sun Dec 15 19:40:40 2019 +0100
*
***
*
@ -1525,11 +1525,12 @@ var Point = Base.extend({
},
getDistance: function() {
var point = Point.read(arguments),
var args = arguments,
point = Point.read(args),
x = point.x - this.x,
y = point.y - this.y,
d = x * x + y * y,
squared = Base.read(arguments);
squared = Base.read(args);
return squared ? d : Math.sqrt(d);
},
@ -1596,8 +1597,9 @@ var Point = Base.extend({
},
isClose: function() {
var point = Point.read(arguments),
tolerance = Base.read(arguments);
var args = arguments,
point = Point.read(args),
tolerance = Base.read(args);
return this.getDistance(point) <= tolerance;
},
@ -1648,8 +1650,9 @@ var Point = Base.extend({
statics: {
min: function() {
var point1 = Point.read(arguments),
point2 = Point.read(arguments);
var args = arguments,
point1 = Point.read(args),
point2 = Point.read(args);
return new Point(
Math.min(point1.x, point2.x),
Math.min(point1.y, point2.y)
@ -1657,8 +1660,9 @@ var Point = Base.extend({
},
max: function() {
var point1 = Point.read(arguments),
point2 = Point.read(arguments);
var args = arguments,
point1 = Point.read(args),
point2 = Point.read(args);
return new Point(
Math.max(point1.x, point2.x),
Math.max(point1.y, point2.y)
@ -1905,7 +1909,8 @@ var Rectangle = Base.extend({
beans: true,
initialize: function Rectangle(arg0, arg1, arg2, arg3) {
var type = typeof arg0,
var args = arguments,
type = typeof arg0,
read;
if (type === 'number') {
this._set(arg0, arg1, arg2, arg3);
@ -1913,7 +1918,7 @@ var Rectangle = Base.extend({
} else if (type === 'undefined' || arg0 === null) {
this._set(0, 0, 0, 0);
read = arg0 === null ? 1 : 0;
} else if (arguments.length === 1) {
} else if (args.length === 1) {
if (Array.isArray(arg0)) {
this._set.apply(this, arg0);
read = 1;
@ -1923,21 +1928,20 @@ var Rectangle = Base.extend({
read = 1;
} else if (arg0.from === undefined && arg0.to === undefined) {
this._set(0, 0, 0, 0);
if (Base.readSupported(arguments, this)) {
if (Base.readSupported(args, this)) {
read = 1;
}
}
}
if (read === undefined) {
var frm = Point.readNamed(arguments, 'from'),
next = Base.peek(arguments),
var frm = Point.readNamed(args, 'from'),
next = Base.peek(args),
x = frm.x,
y = frm.y,
width,
height;
if (next && next.x !== undefined
|| Base.hasNamed(arguments, 'to')) {
var to = Point.readNamed(arguments, 'to');
if (next && next.x !== undefined || Base.hasNamed(args, 'to')) {
var to = Point.readNamed(args, 'to');
width = to.x - x;
height = to.y - y;
if (width < 0) {
@ -1949,14 +1953,14 @@ var Rectangle = Base.extend({
height = -height;
}
} else {
var size = Size.read(arguments);
var size = Size.read(args);
width = size.width;
height = size.height;
}
this._set(x, y, width, height);
read = arguments.__index;
read = args.__index;
}
var filtered = arguments.__filtered;
var filtered = args.__filtered;
if (filtered)
this.__filtered = filtered;
if (this.__read)
@ -2316,10 +2320,11 @@ var Matrix = Base.extend({
_class: 'Matrix',
initialize: function Matrix(arg, _dontNotify) {
var count = arguments.length,
var args = arguments,
count = args.length,
ok = true;
if (count >= 6) {
this._set.apply(this, arguments);
this._set.apply(this, args);
} else if (count === 1 || count === 2) {
if (arg instanceof Matrix) {
this._set(arg._a, arg._b, arg._c, arg._d, arg._tx, arg._ty,
@ -2417,8 +2422,9 @@ var Matrix = Base.extend({
},
scale: function() {
var scale = Point.read(arguments),
center = Point.read(arguments, 0, { readNull: true });
var args = arguments,
scale = Point.read(args),
center = Point.read(args, 0, { readNull: true });
if (center)
this.translate(center);
this._a *= scale.x;
@ -2455,8 +2461,9 @@ var Matrix = Base.extend({
},
shear: function() {
var shear = Point.read(arguments),
center = Point.read(arguments, 0, { readNull: true });
var args = arguments,
shear = Point.read(args),
center = Point.read(args, 0, { readNull: true });
if (center)
this.translate(center);
var a = this._a,
@ -2472,8 +2479,9 @@ var Matrix = Base.extend({
},
skew: function() {
var skew = Point.read(arguments),
center = Point.read(arguments, 0, { readNull: true }),
var args = arguments,
skew = Point.read(args),
center = Point.read(args, 0, { readNull: true }),
toRadians = Math.PI / 180,
shear = new Point(Math.tan(skew.x * toRadians),
Math.tan(skew.y * toRadians));
@ -3938,14 +3946,16 @@ new function() {
},
new function() {
function hitTest() {
var args = arguments;
return this._hitTest(
Point.read(arguments),
HitResult.getOptions(arguments));
Point.read(args),
HitResult.getOptions(args));
}
function hitTestAll() {
var point = Point.read(arguments),
options = HitResult.getOptions(arguments),
var args = arguments,
point = Point.read(args),
options = HitResult.getOptions(args),
all = [];
this._hitTest(point, new Base({ all: all }, options));
return all;
@ -4494,8 +4504,9 @@ new function() {
}, Base.each(['rotate', 'scale', 'shear', 'skew'], function(key) {
var rotate = key === 'rotate';
this[key] = function() {
var value = (rotate ? Base : Point).read(arguments),
center = Point.read(arguments, 0, { readNull: true });
var args = arguments,
value = (rotate ? Base : Point).read(args),
center = Point.read(args, 0, { readNull: true });
return this.transform(new Matrix()[key](value,
center || this.getPosition(true)));
};
@ -5274,25 +5285,28 @@ statics: new function() {
return {
Circle: function() {
var center = Point.readNamed(arguments, 'center'),
radius = Base.readNamed(arguments, 'radius');
var args = arguments,
center = Point.readNamed(args, 'center'),
radius = Base.readNamed(args, 'radius');
return createShape('circle', center, new Size(radius * 2), radius,
arguments);
args);
},
Rectangle: function() {
var rect = Rectangle.readNamed(arguments, 'rectangle'),
radius = Size.min(Size.readNamed(arguments, 'radius'),
var args = arguments,
rect = Rectangle.readNamed(args, 'rectangle'),
radius = Size.min(Size.readNamed(args, 'radius'),
rect.getSize(true).divide(2));
return createShape('rectangle', rect.getCenter(true),
rect.getSize(true), radius, arguments);
rect.getSize(true), radius, args);
},
Ellipse: function() {
var ellipse = Shape._readEllipse(arguments),
var args = arguments,
ellipse = Shape._readEllipse(args),
radius = ellipse.radius;
return createShape('ellipse', ellipse.center, radius.multiply(2),
radius, arguments);
radius, args);
},
_readEllipse: function(args) {
@ -5651,8 +5665,9 @@ var Raster = Item.extend({
},
setPixel: function() {
var point = Point.read(arguments),
color = Color.read(arguments),
var args = arguments,
point = Point.read(args),
color = Color.read(args),
components = color._convert('rgb'),
alpha = color._alpha,
ctx = this.getContext(true),
@ -8290,13 +8305,14 @@ var Path = PathItem.extend({
this._closed = false;
this._segments = [];
this._version = 0;
var segments = Array.isArray(arg)
var args = arguments,
segments = Array.isArray(arg)
? typeof arg[0] === 'object'
? arg
: arguments
: args
: arg && (arg.size === undefined && (arg.x !== undefined
|| arg.point !== undefined))
? arguments
? args
: null;
if (segments && segments.length > 0) {
this.setSegments(segments);
@ -8548,15 +8564,17 @@ var Path = PathItem.extend({
},
add: function(segment1 ) {
return arguments.length > 1 && typeof segment1 !== 'number'
? this._add(Segment.readList(arguments))
: this._add([ Segment.read(arguments) ])[0];
var args = arguments;
return args.length > 1 && typeof segment1 !== 'number'
? this._add(Segment.readList(args))
: this._add([ Segment.read(args) ])[0];
},
insert: function(index, segment1 ) {
return arguments.length > 2 && typeof segment1 !== 'number'
? this._add(Segment.readList(arguments, 1), index)
: this._add([ Segment.read(arguments, 1) ], index)[0];
var args = arguments;
return args.length > 2 && typeof segment1 !== 'number'
? this._add(Segment.readList(args, 1), index)
: this._add([ Segment.read(args, 1) ], index)[0];
},
addSegment: function() {
@ -9481,17 +9499,19 @@ new function() {
},
cubicCurveTo: function() {
var handle1 = Point.read(arguments),
handle2 = Point.read(arguments),
to = Point.read(arguments),
var args = arguments,
handle1 = Point.read(args),
handle2 = Point.read(args),
to = Point.read(args),
current = getCurrentSegment(this);
current.setHandleOut(handle1.subtract(current._point));
this._add([ new Segment(to, handle2.subtract(to)) ]);
},
quadraticCurveTo: function() {
var handle = Point.read(arguments),
to = Point.read(arguments),
var args = arguments,
handle = Point.read(args),
to = Point.read(args),
current = getCurrentSegment(this)._point;
this.cubicCurveTo(
handle.add(current.subtract(handle).multiply(1 / 3)),
@ -9501,9 +9521,10 @@ new function() {
},
curveTo: function() {
var through = Point.read(arguments),
to = Point.read(arguments),
t = Base.pick(Base.read(arguments), 0.5),
var args = arguments,
through = Point.read(args),
to = Point.read(args),
t = Base.pick(Base.read(args), 0.5),
t1 = 1 - t,
current = getCurrentSegment(this)._point,
handle = through.subtract(current.multiply(t1 * t1))
@ -9515,30 +9536,31 @@ new function() {
},
arcTo: function() {
var abs = Math.abs,
var args = arguments,
abs = Math.abs,
sqrt = Math.sqrt,
current = getCurrentSegment(this),
from = current._point,
to = Point.read(arguments),
to = Point.read(args),
through,
peek = Base.peek(arguments),
peek = Base.peek(args),
clockwise = Base.pick(peek, true),
center, extent, vector, matrix;
if (typeof clockwise === 'boolean') {
var middle = from.add(to).divide(2),
through = middle.add(middle.subtract(from).rotate(
clockwise ? -90 : 90));
} else if (Base.remain(arguments) <= 2) {
} else if (Base.remain(args) <= 2) {
through = to;
to = Point.read(arguments);
to = Point.read(args);
} else if (!from.equals(to)) {
var radius = Size.read(arguments),
var radius = Size.read(args),
isZero = Numerical.isZero;
if (isZero(radius.width) || isZero(radius.height))
return this.lineTo(to);
var rotation = Base.read(arguments),
clockwise = !!Base.read(arguments),
large = !!Base.read(arguments),
var rotation = Base.read(args),
clockwise = !!Base.read(args),
large = !!Base.read(args),
middle = from.add(to).divide(2),
pt = from.subtract(middle).rotate(-rotation),
x = pt.x,
@ -9642,37 +9664,41 @@ new function() {
},
curveBy: function() {
var through = Point.read(arguments),
to = Point.read(arguments),
parameter = Base.read(arguments),
var args = arguments,
through = Point.read(args),
to = Point.read(args),
parameter = Base.read(args),
current = getCurrentSegment(this)._point;
this.curveTo(current.add(through), current.add(to), parameter);
},
cubicCurveBy: function() {
var handle1 = Point.read(arguments),
handle2 = Point.read(arguments),
to = Point.read(arguments),
var args = arguments,
handle1 = Point.read(args),
handle2 = Point.read(args),
to = Point.read(args),
current = getCurrentSegment(this)._point;
this.cubicCurveTo(current.add(handle1), current.add(handle2),
current.add(to));
},
quadraticCurveBy: function() {
var handle = Point.read(arguments),
to = Point.read(arguments),
var args = arguments,
handle = Point.read(args),
to = Point.read(args),
current = getCurrentSegment(this)._point;
this.quadraticCurveTo(current.add(handle), current.add(to));
},
arcBy: function() {
var current = getCurrentSegment(this)._point,
point = current.add(Point.read(arguments)),
clockwise = Base.pick(Base.peek(arguments), true);
var args = arguments,
current = getCurrentSegment(this)._point,
point = current.add(Point.read(args)),
clockwise = Base.pick(Base.peek(args), true);
if (typeof clockwise === 'boolean') {
this.arcTo(point, clockwise);
} else {
this.arcTo(point, current.add(Point.read(arguments)));
this.arcTo(point, current.add(Point.read(args)));
}
},
@ -9923,21 +9949,24 @@ Path.inject({ statics: new function() {
return {
Line: function() {
var args = arguments;
return createPath([
new Segment(Point.readNamed(arguments, 'from')),
new Segment(Point.readNamed(arguments, 'to'))
], false, arguments);
new Segment(Point.readNamed(args, 'from')),
new Segment(Point.readNamed(args, 'to'))
], false, args);
},
Circle: function() {
var center = Point.readNamed(arguments, 'center'),
radius = Base.readNamed(arguments, 'radius');
return createEllipse(center, new Size(radius), arguments);
var args = arguments,
center = Point.readNamed(args, 'center'),
radius = Base.readNamed(args, 'radius');
return createEllipse(center, new Size(radius), args);
},
Rectangle: function() {
var rect = Rectangle.readNamed(arguments, 'rectangle'),
radius = Size.readNamed(arguments, 'radius', 0,
var args = arguments,
rect = Rectangle.readNamed(args, 'rectangle'),
radius = Size.readNamed(args, 'radius', 0,
{ readNull: true }),
bl = rect.getBottomLeft(true),
tl = rect.getTopLeft(true),
@ -9968,23 +9997,25 @@ Path.inject({ statics: new function() {
new Segment(br.subtract(rx, 0), [hx, 0])
];
}
return createPath(segments, true, arguments);
return createPath(segments, true, args);
},
RoundRectangle: '#Rectangle',
Ellipse: function() {
var ellipse = Shape._readEllipse(arguments);
return createEllipse(ellipse.center, ellipse.radius, arguments);
var args = arguments,
ellipse = Shape._readEllipse(args);
return createEllipse(ellipse.center, ellipse.radius, args);
},
Oval: '#Ellipse',
Arc: function() {
var from = Point.readNamed(arguments, 'from'),
through = Point.readNamed(arguments, 'through'),
to = Point.readNamed(arguments, 'to'),
props = Base.getNamed(arguments),
var args = arguments,
from = Point.readNamed(args, 'from'),
through = Point.readNamed(args, 'through'),
to = Point.readNamed(args, 'to'),
props = Base.getNamed(args),
path = new Path(props && props.insert == false
&& Item.NO_INSERT);
path.moveTo(from);
@ -9993,9 +10024,10 @@ Path.inject({ statics: new function() {
},
RegularPolygon: function() {
var center = Point.readNamed(arguments, 'center'),
sides = Base.readNamed(arguments, 'sides'),
radius = Base.readNamed(arguments, 'radius'),
var args = arguments,
center = Point.readNamed(args, 'center'),
sides = Base.readNamed(args, 'sides'),
radius = Base.readNamed(args, 'radius'),
step = 360 / sides,
three = sides % 3 === 0,
vector = new Point(0, three ? -radius : radius),
@ -10004,21 +10036,22 @@ Path.inject({ statics: new function() {
for (var i = 0; i < sides; i++)
segments[i] = new Segment(center.add(
vector.rotate((i + offset) * step)));
return createPath(segments, true, arguments);
return createPath(segments, true, args);
},
Star: function() {
var center = Point.readNamed(arguments, 'center'),
points = Base.readNamed(arguments, 'points') * 2,
radius1 = Base.readNamed(arguments, 'radius1'),
radius2 = Base.readNamed(arguments, 'radius2'),
var args = arguments,
center = Point.readNamed(args, 'center'),
points = Base.readNamed(args, 'points') * 2,
radius1 = Base.readNamed(args, 'radius1'),
radius2 = Base.readNamed(args, 'radius2'),
step = 360 / points,
vector = new Point(0, -1),
segments = new Array(points);
for (var i = 0; i < points; i++)
segments[i] = new Segment(center.add(vector.rotate(step * i)
.multiply(i % 2 ? radius2 : radius1)));
return createPath(segments, true, arguments);
return createPath(segments, true, args);
}
};
}});
@ -13016,8 +13049,9 @@ var View = Base.extend(Emitter, {
}, Base.each(['rotate', 'scale', 'shear', 'skew'], function(key) {
var rotate = key === 'rotate';
this[key] = function() {
var value = (rotate ? Base : Point).read(arguments),
center = Point.read(arguments, 0, { readNull: true });
var args = arguments,
value = (rotate ? Base : Point).read(args),
center = Point.read(args, 0, { readNull: true });
return this.transform(new Matrix()[key](value,
center || this.getCenter(true)));
};

File diff suppressed because one or more lines are too long

2
dist/paper.d.ts vendored
View file

@ -9,7 +9,7 @@
*
* All rights reserved.
*
* Date: Sun Dec 15 14:34:46 2019 +0100
* Date: Sun Dec 15 19:40:40 2019 +0100
*
* This is an auto-generated type definition.
*/