mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 14:10:14 -05:00
Merge branch 'refs/heads/boolean-fix'
This commit is contained in:
commit
24e46bee60
3 changed files with 23 additions and 11 deletions
|
@ -318,7 +318,11 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
|||
// If the item already had a name, remove the reference to it from the
|
||||
// parent's children object:
|
||||
if (this._name)
|
||||
this._removeFromNamed();
|
||||
this._removeNamed();
|
||||
// See if the name is a simple number, which we cannot support due to
|
||||
// the named lookup on the children array.
|
||||
if (name === (+name) + '')
|
||||
throw 'Names consisting only of numbers are not supported.'
|
||||
if (name && this._parent) {
|
||||
var children = this._parent._children,
|
||||
namedChildren = this._parent._namedChildren,
|
||||
|
@ -1739,7 +1743,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
|||
/**
|
||||
* Removes the item from its parent's named children list.
|
||||
*/
|
||||
_removeFromNamed: function() {
|
||||
_removeNamed: function() {
|
||||
var children = this._parent._children,
|
||||
namedChildren = this._parent._namedChildren,
|
||||
name = this._name,
|
||||
|
@ -1768,7 +1772,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
|||
_remove: function(notify) {
|
||||
if (this._parent) {
|
||||
if (this._name)
|
||||
this._removeFromNamed();
|
||||
this._removeNamed();
|
||||
if (this._index != null)
|
||||
Base.splice(this._parent._children, null, this._index, 1);
|
||||
// Notify parent of changed hierarchy
|
||||
|
|
|
@ -1395,12 +1395,15 @@ new function() { // Scope for methods that require numerical integration
|
|||
var point = Curve.evaluate(vcr, t, 0);
|
||||
// We do have a point on the infinite line. Check if it falls on
|
||||
// the line *segment*.
|
||||
if (point.x >= 0 && point.x <= rl2x)
|
||||
if (point.x >= 0 && point.x <= rl2x) {
|
||||
// Interpolate the parameter for the intersection on line.
|
||||
var tl = point.x / rl2x,
|
||||
t1 = flip ? tl : t,
|
||||
t2 = flip ? t : tl;
|
||||
addLocation(locations,
|
||||
flip ? curve2 : curve1,
|
||||
// The actual intersection point
|
||||
t, Curve.evaluate(vc, t, 0),
|
||||
flip ? curve1 : curve2);
|
||||
curve1, t1, Curve.evaluate(v1, t1, 0),
|
||||
curve2, t2, Curve.evaluate(v2, t2, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ PathItem.inject(new function() {
|
|||
if (others)
|
||||
others.push(other);
|
||||
segment._intersection = other;
|
||||
loc._segment = segment;
|
||||
}
|
||||
return others;
|
||||
}
|
||||
|
@ -112,10 +113,14 @@ PathItem.inject(new function() {
|
|||
// result of that on to the second call.
|
||||
splitPath(splitPath(intersections, true));
|
||||
// Do operator specific calculations before we begin
|
||||
if (subtract) {
|
||||
// Make both paths at clockwise orientation, except when @subtract = true
|
||||
// We need both paths at opposit orientation for subtraction
|
||||
if (!path1Clockwise)
|
||||
path1.reverse();
|
||||
if (!(subtract ^ path2Clockwise))
|
||||
path2.reverse();
|
||||
path2Clockwise = !path2Clockwise;
|
||||
}
|
||||
path1Clockwise = true;
|
||||
path2Clockwise = !subtract;
|
||||
var paths = []
|
||||
.concat(path1._children || [path1])
|
||||
.concat(path2._children || [path2]),
|
||||
|
|
Loading…
Reference in a new issue