Wrote failing test for strokeBounds on paths with a single segment and strokeColor. Implemented fix for failing test.

This commit is contained in:
msand 2013-12-07 15:59:45 +02:00
parent 758c9b6146
commit 73b1b9843a
2 changed files with 13 additions and 1 deletions

View file

@ -2672,7 +2672,11 @@ statics: {
// Calculate the corner points of butt and square caps // Calculate the corner points of butt and square caps
var point = segment._point, var point = segment._point,
loc = segment.getLocation(), loc = segment.getLocation(),
normal = loc.getNormal().normalize(radius); normal;
if (!loc) {
return;
}
normal = loc.getNormal().normalize(radius);
if (area) { if (area) {
addPoint(point.subtract(normal)); addPoint(point.subtract(normal));
addPoint(point.add(normal)); addPoint(point.add(normal));

View file

@ -74,6 +74,14 @@ test('path.strokeBounds on path without stroke', function() {
compareRectangles(path.strokeBounds, { x: 121, y: 275.068, width: 149.49305, height: 145.87682 }); compareRectangles(path.strokeBounds, { x: 121, y: 275.068, width: 149.49305, height: 145.87682 });
}); });
test('path.strokeBounds on path with single segment and stroke color', function() {
var path = new Path([
new Segment(new Point(121, 334), new Point(-19, 38), new Point(30.7666015625, -61.53369140625))
]);
path.style.strokeColor = 'black';
compareRectangles(path.strokeBounds, { x: 121, y: 334, width: 0, height: 0 });
});
test('path.bounds & path.strokeBounds with stroke styles', function() { test('path.bounds & path.strokeBounds with stroke styles', function() {
function makePath() { function makePath() {
var path = new Path(); var path = new Path();