mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Clean up Curve#divide() code.
This commit is contained in:
parent
3101989974
commit
85de8a0b7d
1 changed files with 9 additions and 11 deletions
|
@ -393,26 +393,24 @@ var Curve = this.Curve = Base.extend(/** @lends Curve# */{
|
||||||
var parts = Curve.subdivide(this.getValues(), parameter),
|
var parts = Curve.subdivide(this.getValues(), parameter),
|
||||||
isLinear = this.isLinear(),
|
isLinear = this.isLinear(),
|
||||||
left = parts[0],
|
left = parts[0],
|
||||||
right = parts[1],
|
right = parts[1];
|
||||||
point1 = this._segment1._point,
|
|
||||||
point2 = this._segment2._point;
|
|
||||||
|
|
||||||
// Write back the results:
|
// Write back the results:
|
||||||
if (!isLinear) {
|
if (!isLinear) {
|
||||||
this._segment1._handleOut.set(left[2] - point1._x,
|
this._segment1._handleOut.set(left[2] - left[0],
|
||||||
left[3] - point1._y);
|
left[3] - left[1]);
|
||||||
// segment2 is the end segment. By inserting newSegment
|
// segment2 is the end segment. By inserting newSegment
|
||||||
// between segment1 and 2, 2 becomes the end segment.
|
// between segment1 and 2, 2 becomes the end segment.
|
||||||
// Convert absolute -> relative
|
// Convert absolute -> relative
|
||||||
this._segment2._handleIn.set(right[4] - point2._x,
|
this._segment2._handleIn.set(right[4] - right[6],
|
||||||
right[5] - point2._y);
|
right[5] - right[7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the new segment, convert absolute -> relative:
|
// Create the new segment, convert absolute -> relative:
|
||||||
var x = left[6], y = left[7],
|
var x = left[6], y = left[7],
|
||||||
segment = new Segment(Point.create(x, y),
|
segment = new Segment(Point.create(x, y),
|
||||||
isLinear ? null : Point.create(left[4] - x, left[5] - y),
|
!isLinear && Point.create(left[4] - x, left[5] - y),
|
||||||
isLinear ? null : Point.create(right[2] - x, right[3] - y));
|
!isLinear && Point.create(right[2] - x, right[3] - y));
|
||||||
|
|
||||||
// Insert it in the segments list, if needed:
|
// Insert it in the segments list, if needed:
|
||||||
if (this._path) {
|
if (this._path) {
|
||||||
|
@ -427,8 +425,8 @@ var Curve = this.Curve = Base.extend(/** @lends Curve# */{
|
||||||
// become the owner of the newly inserted segment.
|
// become the owner of the newly inserted segment.
|
||||||
// TODO: I expect this.getNext() to produce the correct result,
|
// TODO: I expect this.getNext() to produce the correct result,
|
||||||
// but since we're inserting differently in _add (something
|
// but since we're inserting differently in _add (something
|
||||||
// linked with CurveLocation#dividie()), this is not the case...
|
// linked with CurveLocation#divide()), this is not the case...
|
||||||
res = this;
|
res = this; // this.getNext();
|
||||||
} else {
|
} else {
|
||||||
// otherwise create it from the result of split
|
// otherwise create it from the result of split
|
||||||
var end = this._segment2;
|
var end = this._segment2;
|
||||||
|
|
Loading…
Reference in a new issue