Skip to content

Commit

Permalink
Fix Path.Constructor createPath arguments if { insert: true }
Browse files Browse the repository at this point in the history
  • Loading branch information
HriBB authored and lehni committed Oct 20, 2022
1 parent b85d4c5 commit 8be1e34
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/path/Path.Constructors.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ Path.inject({ statics: new function() {

function createPath(segments, closed, args) {
var props = Base.getNamed(args),
path = new Path(props && props.insert == false && Item.NO_INSERT);
path = new Path(props && (props.insert == true
? { insert: true }
: props.insert == false && Item.NO_INSERT
));
path._add(segments);
// No need to use setter for _closed since _add() called _changed().
path._closed = closed;
Expand Down
7 changes: 7 additions & 0 deletions test/tests/Path_Constructors.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ test('new Path.Circle({ center: [100, 100], radius: 50 })', function() {
equals(path.segments.toString(), '{ point: { x: 50, y: 100 }, handleIn: { x: 0, y: 27.61424 }, handleOut: { x: 0, y: -27.61424 } },{ point: { x: 100, y: 50 }, handleIn: { x: -27.61424, y: 0 }, handleOut: { x: 27.61424, y: 0 } },{ point: { x: 150, y: 100 }, handleIn: { x: 0, y: -27.61424 }, handleOut: { x: 0, y: 27.61424 } },{ point: { x: 100, y: 150 }, handleIn: { x: 27.61424, y: 0 }, handleOut: { x: -27.61424, y: 0 } }');
});

test('new Path.Circle({ center: [100, 100], radius: 50, insert: true })', function() {
paper.settings.insertItems = false;
var path = new Path.Circle({ center: [100, 100], radius: 50, insert: true });
equals(path.isInserted(), true);
paper.settings.insertItems = true;
});

test('new Path.Ellipse(rect)', function() {
var rect = new Rectangle([500, 500], [1000, 750]);
var path = new Path.Ellipse(rect);
Expand Down

0 comments on commit 8be1e34

Please sign in to comment.