Prebuilt module for commit 948a8af9a8

This commit is contained in:
Paper.js Bot 2016-05-22 19:20:07 +00:00
parent b3534eca2c
commit 3e446f4e8e
6 changed files with 152 additions and 112 deletions

View file

@ -169,6 +169,10 @@ contribute to the code.
- Allow `Item#position` to be selected via `Item#position.selected` (#980). - Allow `Item#position` to be selected via `Item#position.selected` (#980).
### Fixed ### Fixed
- Fix calculations of `Item#strokeBounds` for all possible combinations of
`Item#strokeScaling` and `Item#applyMatrix` for `Path`, `Shape` and
`SymbolItem`, along with correct handling of such strokes in Item#hitTest()
(#697, #856, #1014).
- Make new code-base unified for Node.js/browser work with module bundlers like - Make new code-base unified for Node.js/browser work with module bundlers like
Webpack (#986). Webpack (#986).
- Improve hit-testing and `#contains()` checks on path with horizontal lines - Improve hit-testing and `#contains()` checks on path with horizontal lines
@ -184,9 +188,6 @@ contribute to the code.
- Do not rasterize items if the resulting raster will be empty (#828). - Do not rasterize items if the resulting raster will be empty (#828).
- Fix SVG serialization in JSDOM `7.0.0` and newer (#821). - Fix SVG serialization in JSDOM `7.0.0` and newer (#821).
- Correctly handle gradients in SVG import on Firefox (#666). - Correctly handle gradients in SVG import on Firefox (#666).
- Fix `Shape#strokeBounds` when `#strokeScaling` is false (#856).
- Correctly handle `#strokeScaling` when calculating `Path` and `Shape` bounds
(#697).
- Consistently interpret curves as straight or not-straight (#838). - Consistently interpret curves as straight or not-straight (#838).
- Switch blendMode to 'lighter' in Candy Crash example for better performance - Switch blendMode to 'lighter' in Candy Crash example for better performance
(#453). (#453).

View file

@ -9,7 +9,7 @@
* *
* All rights reserved. * All rights reserved.
* *
* Date: Sun May 22 17:24:12 2016 +0200 * Date: Sun May 22 21:17:24 2016 +0200
* *
*** ***
* *
@ -3221,8 +3221,10 @@ new function() {
}, },
_getStrokeMatrix: function(matrix, options) { _getStrokeMatrix: function(matrix, options) {
return this.getStrokeScaling() ? matrix : (options && options.internal var mx = this.getStrokeScaling() ? matrix : (options && options.internal
? this : this._parent).getViewMatrix().invert()._shiftless(); ? this : this._parent || this._parentSymbol._item)
.getViewMatrix().invert();
return mx && mx._shiftless();
}, },
statics: { statics: {
@ -3631,7 +3633,9 @@ new function() {
viewMatrix = parentViewMatrix viewMatrix = parentViewMatrix
? parentViewMatrix.appended(matrix) ? parentViewMatrix.appended(matrix)
: this.getGlobalMatrix().prepend(this.getView()._matrix), : this.getGlobalMatrix().prepend(this.getView()._matrix),
strokeMatrix = viewMatrix.inverted(), strokeMatrix = this.getStrokeScaling()
? null
: viewMatrix.inverted()._shiftless(),
tolerance = Math.max(options.tolerance, 1e-6), tolerance = Math.max(options.tolerance, 1e-6),
tolerancePadding = options._tolerancePadding = new Size( tolerancePadding = options._tolerancePadding = new Size(
Path._getStrokePadding(tolerance, strokeMatrix)); Path._getStrokePadding(tolerance, strokeMatrix));
@ -8309,8 +8313,7 @@ var Path = PathItem.extend({
cap = style.getStrokeCap(); cap = style.getStrokeCap();
miterLimit = strokeRadius * style.getMiterLimit(); miterLimit = strokeRadius * style.getMiterLimit();
strokePadding = strokePadding.add( strokePadding = strokePadding.add(
Path._getStrokePadding(strokeRadius, Path._getStrokePadding(strokeRadius, strokeMatrix));
!style.getStrokeScaling() && strokeMatrix));
} else { } else {
join = cap = 'round'; join = cap = 'round';
} }
@ -8354,10 +8357,10 @@ var Path = PathItem.extend({
if (join !== 'round' && (segment._handleIn.isZero() if (join !== 'round' && (segment._handleIn.isZero()
|| segment._handleOut.isZero())) || segment._handleOut.isZero()))
Path._addBevelJoin(segment, join, strokeRadius, Path._addBevelJoin(segment, join, strokeRadius,
miterLimit, addToArea, true); miterLimit, null, strokeMatrix, addToArea, true);
} else if (cap !== 'round') { } else if (cap !== 'round') {
Path._addSquareCap(segment, cap, strokeRadius, addToArea, Path._addSquareCap(segment, cap, strokeRadius, null,
true); strokeMatrix, addToArea, true);
} }
if (!area.isEmpty()) { if (!area.isEmpty()) {
var loc; var loc;
@ -8900,15 +8903,13 @@ statics: {
miterLimit = strokeRadius * style.getMiterLimit(), miterLimit = strokeRadius * style.getMiterLimit(),
joinBounds = new Rectangle(new Size(strokePadding)); joinBounds = new Rectangle(new Size(strokePadding));
function add(point) { function addPoint(point) {
bounds = bounds.include(strokeMatrix bounds = bounds.include(point);
? strokeMatrix._transformPoint(point, point) : point);
} }
function addRound(segment) { function addRound(segment) {
var point = segment._point; bounds = bounds.unite(
bounds = bounds.unite(joinBounds.setCenter(matrix joinBounds.setCenter(segment._point.transform(matrix)));
? matrix._transformPoint(point) : point));
} }
function addJoin(segment, join) { function addJoin(segment, join) {
@ -8918,7 +8919,8 @@ statics: {
&& handleIn.isCollinear(handleOut)) { && handleIn.isCollinear(handleOut)) {
addRound(segment); addRound(segment);
} else { } else {
Path._addBevelJoin(segment, join, strokeRadius, miterLimit, add); Path._addBevelJoin(segment, join, strokeRadius, miterLimit,
matrix, strokeMatrix, addPoint);
} }
} }
@ -8926,7 +8928,8 @@ statics: {
if (cap === 'round') { if (cap === 'round') {
addRound(segment); addRound(segment);
} else { } else {
Path._addSquareCap(segment, cap, strokeRadius, add); Path._addSquareCap(segment, cap, strokeRadius, matrix,
strokeMatrix, addPoint);
} }
} }
@ -8945,9 +8948,8 @@ statics: {
_getStrokePadding: function(radius, matrix) { _getStrokePadding: function(radius, matrix) {
if (!matrix) if (!matrix)
return [radius, radius]; return [radius, radius];
var mx = matrix._shiftless(), var hor = new Point(radius, 0).transform(matrix),
hor = mx.transform(new Point(radius, 0)), ver = new Point(0, radius).transform(matrix),
ver = mx.transform(new Point(0, radius)),
phi = hor.getAngleInRadians(), phi = hor.getAngleInRadians(),
a = hor.getLength(), a = hor.getLength(),
b = ver.getLength(); b = ver.getLength();
@ -8960,7 +8962,8 @@ statics: {
Math.abs(b * Math.sin(ty) * cos + a * Math.cos(ty) * sin)]; Math.abs(b * Math.sin(ty) * cos + a * Math.cos(ty) * sin)];
}, },
_addBevelJoin: function(segment, join, radius, miterLimit, addPoint, area) { _addBevelJoin: function(segment, join, radius, miterLimit, matrix,
strokeMatrix, addPoint, isArea) {
var curve2 = segment.getCurve(), var curve2 = segment.getCurve(),
curve1 = curve2.getPrevious(), curve1 = curve2.getPrevious(),
point = curve2.getPointAtTime(0), point = curve2.getPointAtTime(0),
@ -8969,40 +8972,50 @@ statics: {
step = normal1.getDirectedAngle(normal2) < 0 ? -radius : radius; step = normal1.getDirectedAngle(normal2) < 0 ? -radius : radius;
normal1.setLength(step); normal1.setLength(step);
normal2.setLength(step); normal2.setLength(step);
if (area) { if (matrix)
matrix._transformPoint(point, point);
if (strokeMatrix) {
strokeMatrix._transformPoint(normal1, normal1);
strokeMatrix._transformPoint(normal2, normal2);
}
if (isArea) {
addPoint(point); addPoint(point);
addPoint(point.add(normal1)); addPoint(point.add(normal1));
} }
if (join === 'miter') { if (join === 'miter') {
var corner = new Line( var corner = new Line(point.add(normal1),
point.add(normal1),
new Point(-normal1.y, normal1.x), true new Point(-normal1.y, normal1.x), true
).intersect(new Line( ).intersect(new Line(point.add(normal2),
point.add(normal2),
new Point(-normal2.y, normal2.x), true new Point(-normal2.y, normal2.x), true
), true); ), true);
if (corner && point.getDistance(corner) <= miterLimit) { if (corner && point.getDistance(corner) <= miterLimit) {
addPoint(corner); addPoint(corner);
if (!area) if (!isArea)
return; return;
} }
} }
if (!area) if (!isArea)
addPoint(point.add(normal1)); addPoint(point.add(normal1));
addPoint(point.add(normal2)); addPoint(point.add(normal2));
}, },
_addSquareCap: function(segment, cap, radius, addPoint, area) { _addSquareCap: function(segment, cap, radius, matrix, strokeMatrix,
addPoint, isArea) {
var point = segment._point, var point = segment._point,
loc = segment.getLocation(), loc = segment.getLocation(),
normal = loc.getNormal().multiply(radius); normal = loc.getNormal().multiply(radius);
if (area) { if (matrix)
matrix._transformPoint(point, point);
if (strokeMatrix)
strokeMatrix._transformPoint(normal, normal);
if (isArea) {
addPoint(point.subtract(normal)); addPoint(point.subtract(normal));
addPoint(point.add(normal)); addPoint(point.add(normal));
} }
if (cap === 'square') if (cap === 'square') {
point = point.add(normal.rotate( point = point.add(normal.rotate(
loc.getTime() === 0 ? -90 : 90)); loc.getTime() === 0 ? -90 : 90));
}
addPoint(point.add(normal)); addPoint(point.add(normal));
addPoint(point.subtract(normal)); addPoint(point.subtract(normal));
}, },

75
dist/paper-core.js vendored
View file

@ -9,7 +9,7 @@
* *
* All rights reserved. * All rights reserved.
* *
* Date: Sun May 22 17:24:12 2016 +0200 * Date: Sun May 22 21:17:24 2016 +0200
* *
*** ***
* *
@ -3221,8 +3221,10 @@ new function() {
}, },
_getStrokeMatrix: function(matrix, options) { _getStrokeMatrix: function(matrix, options) {
return this.getStrokeScaling() ? matrix : (options && options.internal var mx = this.getStrokeScaling() ? matrix : (options && options.internal
? this : this._parent).getViewMatrix().invert()._shiftless(); ? this : this._parent || this._parentSymbol._item)
.getViewMatrix().invert();
return mx && mx._shiftless();
}, },
statics: { statics: {
@ -3631,7 +3633,9 @@ new function() {
viewMatrix = parentViewMatrix viewMatrix = parentViewMatrix
? parentViewMatrix.appended(matrix) ? parentViewMatrix.appended(matrix)
: this.getGlobalMatrix().prepend(this.getView()._matrix), : this.getGlobalMatrix().prepend(this.getView()._matrix),
strokeMatrix = viewMatrix.inverted(), strokeMatrix = this.getStrokeScaling()
? null
: viewMatrix.inverted()._shiftless(),
tolerance = Math.max(options.tolerance, 1e-6), tolerance = Math.max(options.tolerance, 1e-6),
tolerancePadding = options._tolerancePadding = new Size( tolerancePadding = options._tolerancePadding = new Size(
Path._getStrokePadding(tolerance, strokeMatrix)); Path._getStrokePadding(tolerance, strokeMatrix));
@ -8309,8 +8313,7 @@ var Path = PathItem.extend({
cap = style.getStrokeCap(); cap = style.getStrokeCap();
miterLimit = strokeRadius * style.getMiterLimit(); miterLimit = strokeRadius * style.getMiterLimit();
strokePadding = strokePadding.add( strokePadding = strokePadding.add(
Path._getStrokePadding(strokeRadius, Path._getStrokePadding(strokeRadius, strokeMatrix));
!style.getStrokeScaling() && strokeMatrix));
} else { } else {
join = cap = 'round'; join = cap = 'round';
} }
@ -8354,10 +8357,10 @@ var Path = PathItem.extend({
if (join !== 'round' && (segment._handleIn.isZero() if (join !== 'round' && (segment._handleIn.isZero()
|| segment._handleOut.isZero())) || segment._handleOut.isZero()))
Path._addBevelJoin(segment, join, strokeRadius, Path._addBevelJoin(segment, join, strokeRadius,
miterLimit, addToArea, true); miterLimit, null, strokeMatrix, addToArea, true);
} else if (cap !== 'round') { } else if (cap !== 'round') {
Path._addSquareCap(segment, cap, strokeRadius, addToArea, Path._addSquareCap(segment, cap, strokeRadius, null,
true); strokeMatrix, addToArea, true);
} }
if (!area.isEmpty()) { if (!area.isEmpty()) {
var loc; var loc;
@ -8900,15 +8903,13 @@ statics: {
miterLimit = strokeRadius * style.getMiterLimit(), miterLimit = strokeRadius * style.getMiterLimit(),
joinBounds = new Rectangle(new Size(strokePadding)); joinBounds = new Rectangle(new Size(strokePadding));
function add(point) { function addPoint(point) {
bounds = bounds.include(strokeMatrix bounds = bounds.include(point);
? strokeMatrix._transformPoint(point, point) : point);
} }
function addRound(segment) { function addRound(segment) {
var point = segment._point; bounds = bounds.unite(
bounds = bounds.unite(joinBounds.setCenter(matrix joinBounds.setCenter(segment._point.transform(matrix)));
? matrix._transformPoint(point) : point));
} }
function addJoin(segment, join) { function addJoin(segment, join) {
@ -8918,7 +8919,8 @@ statics: {
&& handleIn.isCollinear(handleOut)) { && handleIn.isCollinear(handleOut)) {
addRound(segment); addRound(segment);
} else { } else {
Path._addBevelJoin(segment, join, strokeRadius, miterLimit, add); Path._addBevelJoin(segment, join, strokeRadius, miterLimit,
matrix, strokeMatrix, addPoint);
} }
} }
@ -8926,7 +8928,8 @@ statics: {
if (cap === 'round') { if (cap === 'round') {
addRound(segment); addRound(segment);
} else { } else {
Path._addSquareCap(segment, cap, strokeRadius, add); Path._addSquareCap(segment, cap, strokeRadius, matrix,
strokeMatrix, addPoint);
} }
} }
@ -8945,9 +8948,8 @@ statics: {
_getStrokePadding: function(radius, matrix) { _getStrokePadding: function(radius, matrix) {
if (!matrix) if (!matrix)
return [radius, radius]; return [radius, radius];
var mx = matrix._shiftless(), var hor = new Point(radius, 0).transform(matrix),
hor = mx.transform(new Point(radius, 0)), ver = new Point(0, radius).transform(matrix),
ver = mx.transform(new Point(0, radius)),
phi = hor.getAngleInRadians(), phi = hor.getAngleInRadians(),
a = hor.getLength(), a = hor.getLength(),
b = ver.getLength(); b = ver.getLength();
@ -8960,7 +8962,8 @@ statics: {
Math.abs(b * Math.sin(ty) * cos + a * Math.cos(ty) * sin)]; Math.abs(b * Math.sin(ty) * cos + a * Math.cos(ty) * sin)];
}, },
_addBevelJoin: function(segment, join, radius, miterLimit, addPoint, area) { _addBevelJoin: function(segment, join, radius, miterLimit, matrix,
strokeMatrix, addPoint, isArea) {
var curve2 = segment.getCurve(), var curve2 = segment.getCurve(),
curve1 = curve2.getPrevious(), curve1 = curve2.getPrevious(),
point = curve2.getPointAtTime(0), point = curve2.getPointAtTime(0),
@ -8969,40 +8972,50 @@ statics: {
step = normal1.getDirectedAngle(normal2) < 0 ? -radius : radius; step = normal1.getDirectedAngle(normal2) < 0 ? -radius : radius;
normal1.setLength(step); normal1.setLength(step);
normal2.setLength(step); normal2.setLength(step);
if (area) { if (matrix)
matrix._transformPoint(point, point);
if (strokeMatrix) {
strokeMatrix._transformPoint(normal1, normal1);
strokeMatrix._transformPoint(normal2, normal2);
}
if (isArea) {
addPoint(point); addPoint(point);
addPoint(point.add(normal1)); addPoint(point.add(normal1));
} }
if (join === 'miter') { if (join === 'miter') {
var corner = new Line( var corner = new Line(point.add(normal1),
point.add(normal1),
new Point(-normal1.y, normal1.x), true new Point(-normal1.y, normal1.x), true
).intersect(new Line( ).intersect(new Line(point.add(normal2),
point.add(normal2),
new Point(-normal2.y, normal2.x), true new Point(-normal2.y, normal2.x), true
), true); ), true);
if (corner && point.getDistance(corner) <= miterLimit) { if (corner && point.getDistance(corner) <= miterLimit) {
addPoint(corner); addPoint(corner);
if (!area) if (!isArea)
return; return;
} }
} }
if (!area) if (!isArea)
addPoint(point.add(normal1)); addPoint(point.add(normal1));
addPoint(point.add(normal2)); addPoint(point.add(normal2));
}, },
_addSquareCap: function(segment, cap, radius, addPoint, area) { _addSquareCap: function(segment, cap, radius, matrix, strokeMatrix,
addPoint, isArea) {
var point = segment._point, var point = segment._point,
loc = segment.getLocation(), loc = segment.getLocation(),
normal = loc.getNormal().multiply(radius); normal = loc.getNormal().multiply(radius);
if (area) { if (matrix)
matrix._transformPoint(point, point);
if (strokeMatrix)
strokeMatrix._transformPoint(normal, normal);
if (isArea) {
addPoint(point.subtract(normal)); addPoint(point.subtract(normal));
addPoint(point.add(normal)); addPoint(point.add(normal));
} }
if (cap === 'square') if (cap === 'square') {
point = point.add(normal.rotate( point = point.add(normal.rotate(
loc.getTime() === 0 ? -90 : 90)); loc.getTime() === 0 ? -90 : 90));
}
addPoint(point.add(normal)); addPoint(point.add(normal));
addPoint(point.subtract(normal)); addPoint(point.subtract(normal));
}, },

File diff suppressed because one or more lines are too long

75
dist/paper-full.js vendored
View file

@ -9,7 +9,7 @@
* *
* All rights reserved. * All rights reserved.
* *
* Date: Sun May 22 17:24:12 2016 +0200 * Date: Sun May 22 21:17:24 2016 +0200
* *
*** ***
* *
@ -3221,8 +3221,10 @@ new function() {
}, },
_getStrokeMatrix: function(matrix, options) { _getStrokeMatrix: function(matrix, options) {
return this.getStrokeScaling() ? matrix : (options && options.internal var mx = this.getStrokeScaling() ? matrix : (options && options.internal
? this : this._parent).getViewMatrix().invert()._shiftless(); ? this : this._parent || this._parentSymbol._item)
.getViewMatrix().invert();
return mx && mx._shiftless();
}, },
statics: { statics: {
@ -3631,7 +3633,9 @@ new function() {
viewMatrix = parentViewMatrix viewMatrix = parentViewMatrix
? parentViewMatrix.appended(matrix) ? parentViewMatrix.appended(matrix)
: this.getGlobalMatrix().prepend(this.getView()._matrix), : this.getGlobalMatrix().prepend(this.getView()._matrix),
strokeMatrix = viewMatrix.inverted(), strokeMatrix = this.getStrokeScaling()
? null
: viewMatrix.inverted()._shiftless(),
tolerance = Math.max(options.tolerance, 1e-6), tolerance = Math.max(options.tolerance, 1e-6),
tolerancePadding = options._tolerancePadding = new Size( tolerancePadding = options._tolerancePadding = new Size(
Path._getStrokePadding(tolerance, strokeMatrix)); Path._getStrokePadding(tolerance, strokeMatrix));
@ -8309,8 +8313,7 @@ var Path = PathItem.extend({
cap = style.getStrokeCap(); cap = style.getStrokeCap();
miterLimit = strokeRadius * style.getMiterLimit(); miterLimit = strokeRadius * style.getMiterLimit();
strokePadding = strokePadding.add( strokePadding = strokePadding.add(
Path._getStrokePadding(strokeRadius, Path._getStrokePadding(strokeRadius, strokeMatrix));
!style.getStrokeScaling() && strokeMatrix));
} else { } else {
join = cap = 'round'; join = cap = 'round';
} }
@ -8354,10 +8357,10 @@ var Path = PathItem.extend({
if (join !== 'round' && (segment._handleIn.isZero() if (join !== 'round' && (segment._handleIn.isZero()
|| segment._handleOut.isZero())) || segment._handleOut.isZero()))
Path._addBevelJoin(segment, join, strokeRadius, Path._addBevelJoin(segment, join, strokeRadius,
miterLimit, addToArea, true); miterLimit, null, strokeMatrix, addToArea, true);
} else if (cap !== 'round') { } else if (cap !== 'round') {
Path._addSquareCap(segment, cap, strokeRadius, addToArea, Path._addSquareCap(segment, cap, strokeRadius, null,
true); strokeMatrix, addToArea, true);
} }
if (!area.isEmpty()) { if (!area.isEmpty()) {
var loc; var loc;
@ -8900,15 +8903,13 @@ statics: {
miterLimit = strokeRadius * style.getMiterLimit(), miterLimit = strokeRadius * style.getMiterLimit(),
joinBounds = new Rectangle(new Size(strokePadding)); joinBounds = new Rectangle(new Size(strokePadding));
function add(point) { function addPoint(point) {
bounds = bounds.include(strokeMatrix bounds = bounds.include(point);
? strokeMatrix._transformPoint(point, point) : point);
} }
function addRound(segment) { function addRound(segment) {
var point = segment._point; bounds = bounds.unite(
bounds = bounds.unite(joinBounds.setCenter(matrix joinBounds.setCenter(segment._point.transform(matrix)));
? matrix._transformPoint(point) : point));
} }
function addJoin(segment, join) { function addJoin(segment, join) {
@ -8918,7 +8919,8 @@ statics: {
&& handleIn.isCollinear(handleOut)) { && handleIn.isCollinear(handleOut)) {
addRound(segment); addRound(segment);
} else { } else {
Path._addBevelJoin(segment, join, strokeRadius, miterLimit, add); Path._addBevelJoin(segment, join, strokeRadius, miterLimit,
matrix, strokeMatrix, addPoint);
} }
} }
@ -8926,7 +8928,8 @@ statics: {
if (cap === 'round') { if (cap === 'round') {
addRound(segment); addRound(segment);
} else { } else {
Path._addSquareCap(segment, cap, strokeRadius, add); Path._addSquareCap(segment, cap, strokeRadius, matrix,
strokeMatrix, addPoint);
} }
} }
@ -8945,9 +8948,8 @@ statics: {
_getStrokePadding: function(radius, matrix) { _getStrokePadding: function(radius, matrix) {
if (!matrix) if (!matrix)
return [radius, radius]; return [radius, radius];
var mx = matrix._shiftless(), var hor = new Point(radius, 0).transform(matrix),
hor = mx.transform(new Point(radius, 0)), ver = new Point(0, radius).transform(matrix),
ver = mx.transform(new Point(0, radius)),
phi = hor.getAngleInRadians(), phi = hor.getAngleInRadians(),
a = hor.getLength(), a = hor.getLength(),
b = ver.getLength(); b = ver.getLength();
@ -8960,7 +8962,8 @@ statics: {
Math.abs(b * Math.sin(ty) * cos + a * Math.cos(ty) * sin)]; Math.abs(b * Math.sin(ty) * cos + a * Math.cos(ty) * sin)];
}, },
_addBevelJoin: function(segment, join, radius, miterLimit, addPoint, area) { _addBevelJoin: function(segment, join, radius, miterLimit, matrix,
strokeMatrix, addPoint, isArea) {
var curve2 = segment.getCurve(), var curve2 = segment.getCurve(),
curve1 = curve2.getPrevious(), curve1 = curve2.getPrevious(),
point = curve2.getPointAtTime(0), point = curve2.getPointAtTime(0),
@ -8969,40 +8972,50 @@ statics: {
step = normal1.getDirectedAngle(normal2) < 0 ? -radius : radius; step = normal1.getDirectedAngle(normal2) < 0 ? -radius : radius;
normal1.setLength(step); normal1.setLength(step);
normal2.setLength(step); normal2.setLength(step);
if (area) { if (matrix)
matrix._transformPoint(point, point);
if (strokeMatrix) {
strokeMatrix._transformPoint(normal1, normal1);
strokeMatrix._transformPoint(normal2, normal2);
}
if (isArea) {
addPoint(point); addPoint(point);
addPoint(point.add(normal1)); addPoint(point.add(normal1));
} }
if (join === 'miter') { if (join === 'miter') {
var corner = new Line( var corner = new Line(point.add(normal1),
point.add(normal1),
new Point(-normal1.y, normal1.x), true new Point(-normal1.y, normal1.x), true
).intersect(new Line( ).intersect(new Line(point.add(normal2),
point.add(normal2),
new Point(-normal2.y, normal2.x), true new Point(-normal2.y, normal2.x), true
), true); ), true);
if (corner && point.getDistance(corner) <= miterLimit) { if (corner && point.getDistance(corner) <= miterLimit) {
addPoint(corner); addPoint(corner);
if (!area) if (!isArea)
return; return;
} }
} }
if (!area) if (!isArea)
addPoint(point.add(normal1)); addPoint(point.add(normal1));
addPoint(point.add(normal2)); addPoint(point.add(normal2));
}, },
_addSquareCap: function(segment, cap, radius, addPoint, area) { _addSquareCap: function(segment, cap, radius, matrix, strokeMatrix,
addPoint, isArea) {
var point = segment._point, var point = segment._point,
loc = segment.getLocation(), loc = segment.getLocation(),
normal = loc.getNormal().multiply(radius); normal = loc.getNormal().multiply(radius);
if (area) { if (matrix)
matrix._transformPoint(point, point);
if (strokeMatrix)
strokeMatrix._transformPoint(normal, normal);
if (isArea) {
addPoint(point.subtract(normal)); addPoint(point.subtract(normal));
addPoint(point.add(normal)); addPoint(point.add(normal));
} }
if (cap === 'square') if (cap === 'square') {
point = point.add(normal.rotate( point = point.add(normal.rotate(
loc.getTime() === 0 ? -90 : 90)); loc.getTime() === 0 ? -90 : 90));
}
addPoint(point.add(normal)); addPoint(point.add(normal));
addPoint(point.subtract(normal)); addPoint(point.subtract(normal));
}, },

File diff suppressed because one or more lines are too long