zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
U
T±dbã@s2ddlZddlmZGdd„dƒZdZdZdZdS)    éNé)ÚEpsImagePluginc@sVeZdZdZddd„Zddd„Zdd„Zd    d
„Zd d „Zd d„Z    dd„Z
ddd„Z dS)ÚPSDrawz{
    Sets up printing to the given file. If ``fp`` is omitted,
    ``sys.stdout.buffer`` or ``sys.stdout`` is assumed.
    NcCs6|s,z tjj}Wntk
r*tj}YnX||_dS)N)ÚsysÚstdoutÚbufferÚAttributeErrorÚfp)Úselfr    ©r úAd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\PIL/PSDraw.pyÚ__init__ s   zPSDraw.__init__cCs:|j d¡|j t¡|j t¡|j d¡i|_dS)z=Set up printing of a document. (Write PostScript DSC header.)sD%!PS-Adobe-3.0
save
/showpage { } def
%%EndComments
%%BeginDocument
s %%EndProlog
N)r    ÚwriteÚ    EDROFF_PSÚVDI_PSÚisofont)r
Úidr r r Úbegin_document(sÿ   zPSDraw.begin_documentcCs&|j d¡t|jdƒr"|j ¡dS)z-Ends printing. (Write PostScript DSC footer.)s%%%EndDocument
restore showpage
%%End
ÚflushN)r    rÚhasattrr)r
r r r Ú end_document8s  zPSDraw.end_documentcCsJt|dƒ}||jkr2|j d||f¡d|j|<|j d||f¡dS)z~
        Selects which font to use.
 
        :param font: A PostScript font name
        :param size: Size in points.
        úUTF-8s#/PSDraw-%s ISOLatin1Encoding /%s E
rs/F0 %d /PSDraw-%s F
N)Úbytesrr    r)r
ÚfontÚsizer r r Úsetfont>s
 
 
 
zPSDraw.setfontcCs|j d||˜¡dS)z¿
        Draws a line between the two points. Coordinates are given in
        PostScript point coordinates (72 points per inch, (0, 0) is the lower
        left corner of the page).
        s%d %d %d %d Vl
N©r    r)r
Zxy0Zxy1r r r ÚlineMsz PSDraw.linecCs|j d|¡dS)z‰
        Draws a rectangle.
 
        :param box: A tuple of four integers, specifying left, bottom, width and
           height.
        s%d %d M 0 %d %d Vr
Nr)r
Úboxr r r Ú    rectangleUszPSDraw.rectanglecCsHt|dƒ}d | d¡¡}d | d¡¡}||f7}|j d|¡dS)zŠ
        Draws text at the given position. You must use
        :py:meth:`~PIL.PSDraw.PSDraw.setfont` before calling this method.
        rs\(ó(s\)ó)s%d %d M (%s) S
N)rÚjoinÚsplitr    r)r
ZxyÚtextr r r r$^s
 
 
z PSDraw.textc Cs2|s|jdkrd}nd}|jdd|}|jdd|}t|d|dƒ}t|d|dƒ}||kr||||}|}||kr”|||}|}||d|d}||d|d}    |j d    ||    f¡||f|jkr||jd}
||jd} |j d
|
| f¡t ||jd d¡|j d ¡d S) z,Draw a PIL image, centered in the given box.Ú1éÈédréHréésgsave
%f %f translate
s %f %f scale
Ns
 
grestore
)ÚmoderÚfloatr    rrZ_save) r
rZimZdpiÚxÚyZxmaxZymaxZdxZdyZsxZsyr r r Úimageis.
  z PSDraw.image)N)N)N) Ú__name__Ú
__module__Ú __qualname__Ú__doc__r rrrrrr$r/r r r r rs
 
     rs×/S { show } bind def
/P { moveto show } bind def
/M { moveto } bind def
/X { 0 rmoveto } bind def
/Y { 0 exch rmoveto } bind def
/E {    findfont
        dup maxlength dict begin
        {
                1 index /FID ne { def } { pop pop } ifelse
        } forall
        /Encoding exch def
        dup /FontName exch def
        currentdict end definefont pop
} bind def
/F {    findfont exch scalefont dup setfont
        [ exch /setfont cvx ] cvx bind def
} bind def
sß/Vm { moveto } bind def
/Va { newpath arcn stroke } bind def
/Vl { moveto lineto stroke } bind def
/Vc { newpath 0 360 arc closepath } bind def
/Vr {   exch dup 0 rlineto
        exch dup 0 exch rlineto
        exch neg 0 rlineto
        0 exch neg rlineto
        setgray fill } bind def
/Tm matrix def
/Ve {   Tm currentmatrix pop
        translate scale newpath 0 0 .5 0 360 arc closepath
        Tm setmatrix
} bind def
/Vf { currentgray exch setgray fill setgray } bind def
sã/landscape false def
/errorBUF 200 string def
/errorNL { currentpoint 10 sub exch pop 72 exch moveto } def
errordict begin /handleerror {
    initmatrix /Courier findfont 10 scalefont setfont
    newpath 72 720 moveto $error begin /newerror false def
    (PostScript Error) show errorNL errorNL
    (Error: ) show
        /errorname load errorBUF cvs show errorNL errorNL
    (Command: ) show
        /command load dup type /stringtype ne { errorBUF cvs } if show
        errorNL errorNL
    (VMstatus: ) show
        vmstatus errorBUF cvs show ( bytes available, ) show
        errorBUF cvs show ( bytes used at level ) show
        errorBUF cvs show errorNL errorNL
    (Operand stargck: ) show errorNL /ostargck load {
        dup type /stringtype ne { errorBUF cvs } if 72 0 rmoveto show errorNL
    } forall errorNL
    (Execution stargck: ) show errorNL /estargck load {
        dup type /stringtype ne { errorBUF cvs } if 72 0 rmoveto show errorNL
    } forall
    end showpage
} def end
)rÚrrrrZERROR_PSr r r r Ú<module>s
 |