MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _write_hatches

Method _write_hatches

lib/matplotlib/backends/backend_svg.py:526–568  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

524 return oid
525
526 def _write_hatches(self):
527 if not len(self._hatchd):
528 return
529 HATCH_SIZE = 72
530 writer = self.writer
531 writer.start('defs')
532 for (path, face, stroke, lw), oid in self._hatchd.values():
533 writer.start(
534 'pattern',
535 id=oid,
536 patternUnits="userSpaceOnUse",
537 x="0", y="0", width=str(HATCH_SIZE),
538 height=str(HATCH_SIZE))
539 path_data = self._convert_path(
540 path,
541 Affine2D()
542 .scale(HATCH_SIZE).scale(1.0, -1.0).translate(0, HATCH_SIZE),
543 simplify=False)
544 if face is None:
545 fill = 'none'
546 else:
547 fill = rgb2hex(face)
548 writer.element(
549 'rect',
550 x="0", y="0", width=str(HATCH_SIZE+1),
551 height=str(HATCH_SIZE+1),
552 fill=fill)
553 hatch_style = {
554 'fill': rgb2hex(stroke),
555 'stroke': rgb2hex(stroke),
556 'stroke-width': str(lw),
557 'stroke-linecap': 'butt',
558 'stroke-linejoin': 'miter'
559 }
560 if stroke[3] < 1:
561 hatch_style['stroke-opacity'] = str(stroke[3])
562 writer.element(
563 'path',
564 d=path_data,
565 style=_generate_css(hatch_style)
566 )
567 writer.end('pattern')
568 writer.end('defs')
569
570 def _get_style_dict(self, gc, rgbFace):
571 """Generate a style string from the GraphicsContext and rgbFace."""

Callers 1

finalizeMethod · 0.95

Calls 9

_convert_pathMethod · 0.95
Affine2DClass · 0.90
_generate_cssFunction · 0.85
valuesMethod · 0.80
translateMethod · 0.80
elementMethod · 0.80
startMethod · 0.45
scaleMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected