Skip to content

Commit bef908a

Browse files
committed
Merge branch 'master' of https://github.com/paperjs/paper.js
2 parents 841c99d + 97e85d6 commit bef908a

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

src/path/Path.Constructors.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@
1212

1313
Path.inject({ statics: new function() {
1414

15+
function createPath(args) {
16+
return new Path().set(Base.getNamed(args));
17+
}
18+
1519
function createRectangle(/* rect */) {
1620
var rect = Rectangle.readNamed(arguments, 'rectangle'),
1721
left = rect.getLeft(),
1822
top = rect.getTop(),
1923
right = rect.getRight(),
2024
bottom = rect.getBottom(),
21-
path = new Path(Base.getNamed(arguments));
25+
path = createPath(arguments);
2226
path._add([
2327
new Segment(Point.create(left, bottom)),
2428
new Segment(Point.create(left, top)),
@@ -41,7 +45,7 @@ Path.inject({ statics: new function() {
4145

4246
function createEllipse(/* rect */) {
4347
var rect = Rectangle.readNamed(arguments, 'rectangle'),
44-
path = new Path(Base.getNamed(arguments)),
48+
path = createPath(arguments),
4549
point = rect.getPoint(true),
4650
size = rect.getSize(true),
4751
segments = new Array(4);
@@ -163,7 +167,7 @@ Path.inject({ statics: new function() {
163167
tr = rect.getTopRight(true),
164168
br = rect.getBottomRight(true),
165169
h = radius.multiply(kappa * 2), // handle vector
166-
path = new Path(Base.getNamed(arguments));
170+
path = createPath(arguments);
167171
path._add([
168172
new Segment(bl.add(radius.width, 0), null, [-h.width, 0]),
169173
new Segment(bl.subtract(0, radius.height), [0, h.height], null),
@@ -244,7 +248,7 @@ Path.inject({ statics: new function() {
244248
var from = Point.readNamed(arguments, 'from'),
245249
through = Point.readNamed(arguments, 'through'),
246250
to = Point.readNamed(arguments, 'to'),
247-
path = new Path(Base.getNamed(arguments));
251+
path = createPath(arguments);
248252
path.moveTo(from);
249253
path.arcTo(through, to);
250254
return path;
@@ -276,7 +280,7 @@ Path.inject({ statics: new function() {
276280
var center = Point.readNamed(arguments, 'center'),
277281
numSides = Base.readNamed(arguments, 'numSides'),
278282
radius = Base.readNamed(arguments, 'radius'),
279-
path = new Path(Base.getNamed(arguments)),
283+
path = createPath(arguments),
280284
step = 360 / numSides,
281285
three = !(numSides % 3),
282286
vector = new Point(0, three ? -radius : radius),
@@ -317,7 +321,7 @@ Path.inject({ statics: new function() {
317321
numPoints = Base.readNamed(arguments, 'numPoints') * 2,
318322
radius1 = Base.readNamed(arguments, 'radius1'),
319323
radius2 = Base.readNamed(arguments, 'radius2'),
320-
path = new Path(Base.getNamed(arguments)),
324+
path = createPath(arguments),
321325
step = 360 / numPoints,
322326
vector = new Point(0, -1),
323327
segments = new Array(numPoints);

0 commit comments

Comments
 (0)