Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0a92c2f

Browse files
committed
FEATURE: Path.get_stroked_extents
1 parente841b51 commit0a92c2f

File tree

7 files changed

+713
-4
lines changed

7 files changed

+713
-4
lines changed

‎doc/users/next_whats_new/2020-03-31-path-size-methods.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,14 @@ Historically, `~.path.Path.get_extents` has always simply returned the Bbox of
2525
a curve's control points, instead of the Bbox of the curve itself. While this is
2626
a correct upper bound for the path's extents, it can differ dramatically from
2727
the Path's actual extents for non-linear Bezier curves.
28+
29+
New function to get Path's *stroked* Bbox
30+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31+
32+
A Path is typically drawn by stroking it (with some ``markeredgewidth``), an
33+
operation which changes its bounding box in a nontrivial way, depending on the
34+
Path's joinstyle, capstyle, miterlimit, and shape.
35+
36+
`~.path.Path.get_stroked_extents` was added to allow computation of the final
37+
bounding box in pixel/points coordinates of the line, after it has been drawn
38+
(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
returnself._N-1
236236

237+
@property
238+
deftan_in(self):
239+
ifself._N<2:
240+
raiseValueError("Need at least two control points to get tangent "
241+
"vector!")
242+
returnself.control_points[1]-self.control_points[0]
243+
244+
@property
245+
deftan_out(self):
246+
ifself._N<2:
247+
raiseValueError("Need at least two control points to get tangent "
248+
"vector!")
249+
returnself.control_points[-1]-self.control_points[-2]
250+
237251
@property
238252
defpolynomial_coefficients(self):
239253
r"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp