MCPcopy Create free account
hub / github.com/ColdGrub1384/Pyto / get_path

Function get_path

site-packages/matplotlib/hatch.py:188–214  ·  view source on GitHub ↗

Given a hatch specifier, *hatchpattern*, generates Path to render the hatch in a unit square. *density* is the number of lines per unit square.

(hatchpattern, density=6)

Source from the content-addressed store, hash-verified

186
187
188def get_path(hatchpattern, density=6):
189 """
190 Given a hatch specifier, *hatchpattern*, generates Path to render
191 the hatch in a unit square. *density* is the number of lines per
192 unit square.
193 """
194 density = int(density)
195
196 patterns = [hatch_type(hatchpattern, density)
197 for hatch_type in _hatch_types]
198 num_vertices = sum([pattern.num_vertices for pattern in patterns])
199
200 if num_vertices == 0:
201 return Path(np.empty((0, 2)))
202
203 vertices = np.empty((num_vertices, 2))
204 codes = np.empty((num_vertices,), np.uint8)
205
206 cursor = 0
207 for pattern in patterns:
208 if pattern.num_vertices != 0:
209 vertices_chunk = vertices[cursor:cursor + pattern.num_vertices]
210 codes_chunk = codes[cursor:cursor + pattern.num_vertices]
211 pattern.set_vertices_and_codes(vertices_chunk, codes_chunk)
212 cursor += pattern.num_vertices
213
214 return Path(vertices, codes)

Callers 1

hatchMethod · 0.90

Calls 4

PathClass · 0.90
sumFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected