8000 FEATURE: Path.get_stroked_extents · matplotlib/matplotlib@265caec · GitHub
[go: up one dir, main page]

Skip to content

Commit 265caec

Browse files
committed
FEATURE: Path.get_stroked_extents
1 parent 6f0b4bc commit 265caec

File tree

7 files changed

+712
-4
lines changed

7 files changed

+712
-4
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
New function to get Path's *stroked* Bbox
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
A Path is typically drawn by stroking it (with some ``markeredgewidth``), an
5+
operation which changes its bounding box in a nontrivial way, depending on the
6+
Path's joinstyle, capstyle, miterlimit, and shape.
7+
8+
`~.path.Path.get_stroked_extents` was added to allow computation of the final
9+
bounding box in pixel/points coordinates of the line, after it has been drawn
10+
(and accounting for the joinstyle, capstyle, and miterlimit).

lib/matplotlib/bezier.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,20 @@ def degree(self):
234234
"""Degree of the polynomial. One less the number of control points."""
235235
return self._N - 1
236236

237+
@property
238+
def tan_in(self):
239+
if self._N < 2:
240+
raise ValueError("Need at least two control points to get tangent "
241+
"vector!")
242+
return self.control_points[1] - self.control_points[0]
243+
244+
@property
245+
def tan_out(self):
246+
if self._N < 2:
247+
raise ValueError("Need at least two control points to get tangent "
248+
"vector!")
249+
return self.control_points[-1] - self.control_points[-2]
250+
237251
@property
238252
def polynomial_coefficients(self):
239253
r"""

0 commit comments

Comments
 (0)
0