Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stroke bounds for paths #41

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/path/Curve.js
Original file line number Diff line number Diff line change
Expand Up @@ -858,8 +858,8 @@ statics: /** @lends Curve */{
}

padding /= 2; // strokePadding is in width, not radius
var minPad = min[coord] - padding,
maxPad = max[coord] + padding;
var minPad = min[coord] + padding,
maxPad = max[coord] - padding;
// Perform a rough bounds checking first: The curve can only extend the
// current bounds if at least one value is outside the min-max range.
if ( v0 < minPad || v1 < minPad || v2 < minPad || v3 < minPad ||
Expand Down
16 changes: 16 additions & 0 deletions test/tests/Item_Bounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -798,3 +798,19 @@ test('#1561 item._globalMatrix on item after empty symbol', function(){
view.update();
equals(item._globalMatrix, new Matrix());
});

test('path.strokeBounds applies stroke padding properly (#1824)', function() {
var ellipse = new Path.Ellipse({
point: [100, 100],
size: [50, 80],
strokeWidth: 32,
strokeColor: 'red'
});

ellipse.rotate(50);
equals(
ellipse.strokeBounds,
new Rectangle(74.39306, 91.93799, 101.21388, 96.12403),
'ellipse.strokeBounds'
);
})