mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Take matrices into account in PathItem#getIntersections()
This commit is contained in:
parent
516b9d040f
commit
8cec512cc2
2 changed files with 21 additions and 12 deletions
|
@ -248,8 +248,8 @@ var Curve = Base.extend(/** @lends Curve# */{
|
|||
this.getPoint2().setSelected(selected);
|
||||
},
|
||||
|
||||
getValues: function() {
|
||||
return Curve.getValues(this._segment1, this._segment2);
|
||||
getValues: function(matrix) {
|
||||
return Curve.getValues(this._segment1, this._segment2, matrix);
|
||||
},
|
||||
|
||||
getPoints: function() {
|
||||
|
@ -446,17 +446,20 @@ var Curve = Base.extend(/** @lends Curve# */{
|
|||
|
||||
// Mess with indentation in order to get more line-space below...
|
||||
statics: {
|
||||
getValues: function(segment1, segment2) {
|
||||
getValues: function(segment1, segment2, matrix) {
|
||||
var p1 = segment1._point,
|
||||
h1 = segment1._handleOut,
|
||||
h2 = segment2._handleIn,
|
||||
p2 = segment2._point;
|
||||
return [
|
||||
p1._x, p1._y,
|
||||
p1._x + h1._x, p1._y + h1._y,
|
||||
p2._x + h2._x, p2._y + h2._y,
|
||||
p2._x, p2._y
|
||||
];
|
||||
p2 = segment2._point,
|
||||
values = [
|
||||
p1._x, p1._y,
|
||||
p1._x + h1._x, p1._y + h1._y,
|
||||
p2._x + h2._x, p2._y + h2._y,
|
||||
p2._x, p2._y
|
||||
];
|
||||
if (matrix)
|
||||
matrix._transformCoordinates(values, 0, values, 0, 6);
|
||||
return values;
|
||||
},
|
||||
|
||||
evaluate: function(v, t, type) {
|
||||
|
|
|
@ -67,13 +67,19 @@ var PathItem = Item.extend(/** @lends PathItem# */{
|
|||
var locations = [],
|
||||
curves1 = this.getCurves(),
|
||||
curves2 = path.getCurves(),
|
||||
matrix1 = this._matrix,
|
||||
matrix2 = path._matrix,
|
||||
length2 = curves2.length,
|
||||
values2 = [];
|
||||
if (matrix1.isIdentity())
|
||||
matrix1 = null;
|
||||
if (matrix2.isIdentity())
|
||||
matrix2 = null;
|
||||
for (var i = 0; i < length2; i++)
|
||||
values2[i] = curves2[i].getValues();
|
||||
values2[i] = curves2[i].getValues(matrix2);
|
||||
for (var i = 0, l = curves1.length; i < l; i++) {
|
||||
var curve1 = curves1[i],
|
||||
values1 = curve1.getValues();
|
||||
values1 = curve1.getValues(matrix1);
|
||||
for (var j = 0; j < length2; j++)
|
||||
Curve.getIntersections(values1, values2[j], curve1, curves2[j],
|
||||
locations);
|
||||
|
|
Loading…
Reference in a new issue