20
20
21
21
class Path (object ):
22
22
"""
23
- :class:`Path` represents a series of possibly disconnected,
24
- possibly closed, line and curve segments.
23
+ A series of possibly disconnected, possibly closed, line and curve
24
+ segments.
25
25
26
26
The underlying storage is made up of two parallel numpy arrays:
27
- - *vertices*: an Nx2 float array of vertices
28
- - *codes*: an N-length uint8 array of vertex types
27
+
28
+ - *vertices*: an Nx2 float array of vertices
29
+ - *codes*: an N-length uint8 array of vertex types, or None
29
30
30
31
These two arrays always have the same length in the first
31
32
dimension. For example, to represent a cubic curve, you must
32
33
provide three vertices as well as three codes ``CURVE3``.
33
34
34
35
The code types are:
35
36
36
- - ``STOP`` : 1 vertex (ignored)
37
- A marker for the end of the entire path (currently not
38
- required and ignored)
37
+ - ``STOP`` : 1 vertex (ignored)
38
+ A marker for the end of the entire path (currently not required and
39
+ ignored)
40
+
41
+ - ``MOVETO`` : 1 vertex
42
+ Pick up the pen and move to the given vertex.
39
43
40
- - ``MOVETO `` : 1 vertex
41
- Pick up the pen and move to the given vertex.
44
+ - ``LINETO `` : 1 vertex
45
+ Draw a line from the current position to the given vertex.
42
46
43
- - ``LINETO`` : 1 vertex
44
- Draw a line from the current position to the given vertex.
47
+ - ``CURVE3`` : 1 control point, 1 endpoint
48
+ Draw a quadratic Bezier curve from the current position, with the given
49
+ control point, to the given end point.
45
50
46
- - ``CURVE3 `` : 1 control point , 1 endpoint
47
- Draw a quadratic Bezier curve from the current position,
48
- with the given control point , to the given end point.
51
+ - ``CURVE4 `` : 2 control points , 1 endpoint
52
+ Draw a cubic Bezier curve from the current position, with the given
53
+ control points , to the given end point.
49
54
50
- - ``CURVE4`` : 2 control points, 1 endpoint
51
- Draw a cubic Bezier curve from the current position, with
52
- the given control points, to the given end point.
55
+ - ``CLOSEPOLY`` : 1 vertex (ignored)
56
+ Draw a line segment to the start point of the current polyline.
53
57
54
- - ``CLOSEPOLY`` : 1 vertex (ignored)
55
- Draw a line segment to the start point of the current
56
- polyline.
58
+ If *codes* is None, it is interpreted as a ``MOVETO`` followed by a series
59
+ of ``LINETO``.
57
60
58
- Users of Path objects should not access the vertices and codes
59
- arrays directly. Instead, they should use :meth:`iter_segments`
60
- or :meth:`cleaned` to get the vertex/code pairs. This is important,
61
- since many :class:`Path` objects, as an optimization, do not store a
62
- *codes* at all, but have a default one provided for them by
63
- :meth:`iter_segments`.
61
+ Users of Path objects should not access the vertices and codes arrays
62
+ directly. Instead, they should use `iter_segments` or `cleaned` to get the
63
+ vertex/code pairs. This helps, in particular, to consistently handle the
64
+ case of *codes* being None.
64
65
65
- Some behavior of Path objects can be controlled by rcParams. See
66
- the rcParams whose keys contain 'path.'.
66
+ Some behavior of Path objects can be controlled by rcParams. See the
67
+ rcParams whose keys start with 'path.'.
67
68
68
69
.. note::
69
70
70
71
The vertices and codes arrays should be treated as
71
72
immutable -- there are a number of optimizations and assumptions
72
73
made up front in the constructor that will not change when the
73
74
data changes.
74
-
75
75
"""
76
76
77
77
code_type = np .uint8
@@ -496,8 +496,7 @@ def contains_path(self, path, transform=None):
496
496
497
497
def get_extents (self , transform = None ):
498
498
"""
499
- Returns the extents (*xmin*, *ymin*, *xmax*, *ymax*) of the
500
- path.
499
+ Returns the extents (*xmin*, *ymin*, *xmax*, *ymax*) of the path.
501
500
502
501
Unlike computing the extents on the *vertices* alone, this
503
502
algorithm will take into account the curves and deal with
@@ -524,8 +523,7 @@ def intersects_path(self, other, filled=True):
524
523
525
524
def intersects_bbox (self , bbox , filled = True ):
526
525
"""
527
- Returns *True* if this path intersects a given
528
- :class:`~matplotlib.transforms.Bbox`.
526
+ Returns whether this path intersects a given `~.transforms.Bbox`.
529
527
530
528
*filled*, when True, treats the path as if it was filled.
531
529
That is, if the path completely encloses the bounding box,
0 commit comments