8000 Fixed merge conflict on test_patches. · matplotlib/matplotlib@a78d7e8 · GitHub
[go: up one dir, main page]

Skip to content

Commit a78d7e8

Browse files
committed
Fixed merge conflict on test_patches.
2 parents 93cbcb3 + 41fcfd2 commit a78d7e8

File tree

7 files changed

+578
-201
lines changed

7 files changed

+578
-201
lines changed

examples/user_interfaces/printing_in_wx.py

Lines changed: 0 additions & 188 deletions
This file was deleted.

lib/matplotlib/path.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from matplotlib._path import point_in_path, get_path_extents, \
1313
point_in_path_collection, get_path_collection_extents, \
1414
path_in_path, path_intersects_path, convert_path_to_polygons, \
15-
cleanup_path, points_in_path
15+
cleanup_path, points_in_path, clip_path_to_rect
1616
from matplotlib.cbook import simple_linear_interpolation, maxdict
1717
from matplotlib import rcParams
1818

@@ -171,22 +171,23 @@ def make_compound_path_from_polys(cls, XY):
171171
def make_compound_path(cls, *args):
172172
"""
173173
(staticmethod) Make a compound path from a list of Path
174-
objects. Only polygons (not curves) are supported.
174+
objects.
175175
"""
176-
for p in args:
177-
assert p.codes is None
178-
179176
lengths = [len(x) for x in args]
180177
total_length = sum(lengths)
181178

182179
vertices = np.vstack([x.vertices for x in args])
183180
vertices.reshape((total_length, 2))
184181

185-
codes = cls.LINETO * np.ones(total_length)
182+
codes = np.empty(total_length, dtype=cls.code_type)
186183
i = 0
187-
for length in lengths:
188-
codes[i] = cls.MOVETO
189-
i += length
184+
for path in args:
185+
if path.codes is None:
186+
codes[i] = cls.MOVETO
187+
codes[i + 1:i + len(path.vertices)] = cls.LINETO
188+
else:
189+
codes[i:i + len(path.codes)] = path.codes
190+
i += len(path.vertices)
190191

191192
return cls(vertices, codes)
192193

@@ -709,6 +710,22 @@ def hatch(cls, hatchpattern, density=6):
709710
cls._hatch_dict[(hatchpattern, density)] = hatch_path
710711
return hatch_path
711712

713+
def clip_to_bbox(self, bbox, inside=True):
714+
"""
715+
Clip the path to the given bounding box.
716+
717+
The path must be made up of one or more closed polygons. This
718+
algorithm will not behave correctly for unclosed paths.
719+
720+
If *inside* is `True`, clip to the inside of the box, otherwise
721+
to the outside of the box.
722+
"""
723+
# Use make_compound_path_from_polys
724+
verts = clip_path_to_rect(self, bbox, inside)
725+
paths = [Path(poly) for poly in verts]
726+
return self.make_compound_path(*paths)
727+
728+
712729
_get_path_collection_extents = get_path_collection_extents
713730
def get_path_collection_extents(
714731
master_transform, paths, transforms, offsets, offset_transform):
Binary file not shown.
Loading

0 commit comments

Comments
 (0)
0