Skip to content

Stroked path width #17198

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
10 changes: 10 additions & 0 deletions doc/users/next_whats_new/2020-06-17-path-extents.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
New function to get Path's *stroked* Bbox
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

A Path is typically drawn by stroking it (with some ``markeredgewidth``), an
operation which changes its bounding box in a nontrivial way, depending on the
Path's joinstyle, capstyle, miterlimit, and shape.

`~.path.Path.get_stroked_extents` was added to allow computation of the final
bounding box in pixel/points coordinates of the line, after it has been drawn
(and accounting for the joinstyle, capstyle, and miterlimit).
14 changes: 14 additions & 0 deletions lib/matplotlib/bezier.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,20 @@ def degree(self):
"""Degree of the polynomial. One less the number of control points."""
return self._N - 1

@property
def tan_in(self):
if self._N < 2:
raise ValueError("Need at least two control points to get tangent "
"vector!")
return self.control_points[1] - self.control_points[0]

@property
def tan_out(self):
if self._N < 2:
raise ValueError("Need at least two control points to get tangent "
"vector!")
return self.control_points[-1] - self.control_points[-2]

@property
def polynomial_coefficients(self):
r"""
Expand Down
Loading