From 73b1b9843a6771c478d52b5554c35d83a3f7f284 Mon Sep 17 00:00:00 2001 From: msand Date: Sat, 7 Dec 2013 15:59:45 +0200 Subject: [PATCH] Wrote failing test for strokeBounds on paths with a single segment and strokeColor. Implemented fix for failing test. --- src/path/Path.js | 6 +++++- test/tests/Path_Bounds.js | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/path/Path.js b/src/path/Path.js index 1d3d5074..2434f9bd 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -2672,7 +2672,11 @@ statics: { // Calculate the corner points of butt and square caps var point = segment._point, loc = segment.getLocation(), - normal = loc.getNormal().normalize(radius); + normal; + if (!loc) { + return; + } + normal = loc.getNormal().normalize(radius); if (area) { addPoint(point.subtract(normal)); addPoint(point.add(normal)); diff --git a/test/tests/Path_Bounds.js b/test/tests/Path_Bounds.js index 4e18d1b8..69e32646 100644 --- a/test/tests/Path_Bounds.js +++ b/test/tests/Path_Bounds.js @@ -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 }); }); +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() { function makePath() { var path = new Path();