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)
| 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 | |
| 958 | class _Orientation(Enum): |
no test coverage detected