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

Method _draw_ps

lib/matplotlib/backends/backend_ps.py:906–955  ·  view source on GitHub ↗

Emit the PostScript snippet *ps* with all the attributes from *gc* applied. *ps* must consist of PostScript commands to construct a path. The *fill* and/or *stroke* kwargs can be set to False if the *ps* string already includes filling and/or stroking, in which cas

(self, ps, gc, rgbFace, *, fill=True, stroke=True)

Source from the content-addressed store, hash-verified

904""")
905
906 def _draw_ps(self, ps, gc, rgbFace, *, fill=True, stroke=True):
907 """
908 Emit the PostScript snippet *ps* with all the attributes from *gc*
909 applied. *ps* must consist of PostScript commands to construct a path.
910
911 The *fill* and/or *stroke* kwargs can be set to False if the *ps*
912 string already includes filling and/or stroking, in which case
913 `_draw_ps` is just supplying properties and clipping.
914 """
915 write = self._pswriter.write
916 mightstroke = (gc.get_linewidth() > 0
917 and not self._is_transparent(gc.get_rgb()))
918 if not mightstroke:
919 stroke = False
920 if self._is_transparent(rgbFace):
921 fill = False
922 hatch = gc.get_hatch()
923
924 if mightstroke:
925 self.set_linewidth(gc.get_linewidth())
926 self.set_linejoin(gc.get_joinstyle())
927 self.set_linecap(gc.get_capstyle())
928 self.set_linedash(*gc.get_dashes())
929 if mightstroke or hatch:
930 self.set_color(*gc.get_rgb()[:3])
931 write('gsave\n')
932
933 write(self._get_clip_cmd(gc))
934
935 write(ps.strip())
936 write("\n")
937
938 if fill:
939 if stroke or hatch:
940 write("gsave\n")
941 self.set_color(*rgbFace[:3], store=False)
942 write("fill\n")
943 if stroke or hatch:
944 write("grestore\n")
945
946 if hatch:
947 hatch_name = self.create_hatch(hatch, gc.get_hatch_linewidth())
948 write("gsave\n")
949 write(_nums_to_str(*gc.get_hatch_color()[:3]))
950 write(f" {hatch_name} setpattern fill grestore\n")
951
952 if stroke:
953 write("stroke\n")
954
955 write("grestore\n")
956
957
958class _Orientation(Enum):

Callers 3

draw_pathMethod · 0.95
draw_markersMethod · 0.95
draw_path_collectionMethod · 0.95

Calls 15

_is_transparentMethod · 0.95
set_linewidthMethod · 0.95
set_linejoinMethod · 0.95
set_linecapMethod · 0.95
set_linedashMethod · 0.95
set_colorMethod · 0.95
_get_clip_cmdMethod · 0.95
create_hatchMethod · 0.95
_nums_to_strFunction · 0.85
get_dashesMethod · 0.80
get_hatch_colorMethod · 0.80
get_linewidthMethod · 0.45

Tested by

no test coverage detected