creatio ex nihilo
[transyMjolnir.git] / transyMjolnir.ps
blob7a637f3150fe2c81c11ddea2ea45a8eca3952c3c
1 %!PS-Adobe-3.0
2 %%Title: transyMjolnir.ps
3 %%Creator: Candace Hierehāt
4 %%CreationDate: 2017-07-01
5 %%Pages: 1
6 %%BoundingBox: 0 0 128 128
7 %%EndComments
9 % Draw a Mjölnir (Thor's hammer) symbol adorned with the tricolour
10 % of the transgender pride flag.
14 % <n> <f> hammerdo -
15 % create a Mjölnir path within a square of size <n> and call procedure <f>
16 % within the path's context, passing atop the stack the size of the context:
17 %     <sz> <f> -
19 /hammerdo {
20         2 dict begin                            % room for 2 local variables
21         /f exch def                                     % top of stack goes into <f>
22         /s exch def                                     % new top goes into <s>
24         gsave                                           % save the graphics context
25                 s 36290 div dup scale   % scale local coords to fit within <s>x<s>
26                 newpath                                 % start drawing a new path
27                 18145 0 moveto                  % path data...
28                 11842 3800 1528 4560 764 4560 curveto
29                 0 4560 0 5320 0 5320 curveto
30                 0 12160 lineto
31                 14325 11970 13370 15010 13370 15010 curveto
32                 13370 27170 lineto
33                 13370 27170 13561 33250 10314 33250 curveto
34                 10123 33250 10314 36290 10314 36290 curveto
35                 25785 36290 lineto
36                 25785 36290 25785 33250 25785 33250 curveto
37                 22538 33250 22729 27170 22729 27170 curveto
38                 22729 15010 lineto
39                 22729 15010 21774 11970 36290 12160 curveto
40                 36290 5320 lineto
41                 36290 5320 36290 4560 35335 4560 curveto
42                 34571 4560 24257 3800 18145 0 curveto
43                 closepath                               % that's all the data; close the path
44                 36290 f                                 % call <f> with the local coord scale factor
45         grestore                                        % restore the previous graphics context
47         end                                                     % end local scope
48 } def
51 % push some rgb values onto the stack for use with setrgbcolor
52 % - /colour <r> <g> <b>
54 /blue  {  91 255 div 206 255 div 250 255 div } def
55 /pink  { 245 255 div 169 255 div 184 255 div } def
56 /white { 255 255 div 255 255 div 255 255 div } def
59 % <s> flagfill -
60 % draw an <s>x<s> square trans pride flag at the origin
62 /flagfill {
63         2 dict begin                            % room for two local variables
64         /s exch def                                     % pop top of stack into <s>
66         /t s 5 div def                          % height of each stripe
68         blue setrgbcolor                        % fill the background with a blue
69         0 0 s s rectfill                        % <s>x<s> square
70         pink setrgbcolor                        % now paint over part of the bg with a pink,
71         0 t s 3 t mul rectfill          % vertically-centered <s>x<3t> rectangle
72         white setrgbcolor                       % and paint over part of that with a white,
73         0 t t add s t rectfill          % vertically-centered <s>x<t> rectangle
75         end                                                     % end of local scope
76 } def
78 %%EndProlog
82 %%BeginSetup
83 initgraphics
85 /sz  currentpagedevice /PageSize     get 0 get def              % page size
86 /res currentpagedevice /HWResolution get 0 get def              % output DPI
87 /rsb 72 def                                             % the resolutory basis in which to draw
88 /lwd rsb res sub rsb res div dup add div res add def
89                                                 % line width divisor:  (rsb-res) / 2*(rsb/res) + res
90 /ofs sz lwd div 2 mul def               % the desired offset for drop shadow
91 /tsz sz ofs sub def                             % size of the Mjölnir symbol to draw
92 % uncomment to "disable" drop shadow:
93 %/ofs 0  def
94 %/tsz sz def
95 %%EndSetup
98 %%Page: 1 1
99 gsave
100         ofs 0 translate                         % to the right by <lw> units
101         tsz {                                           % draw a drop shadow
102                 pop                                             % don't need the context size here
103                 0 setgray                               % paint it black
104                 fill                                    % fill the hammer shape black
105         } hammerdo
106 grestore                                                % back to the initial graphics state
107 gsave
108         0 ofs translate                         % up by <lw> units
109         tsz {                                           % main attraction
110                 clip flagfill                   % use hammer as clip path when drawing flag
111         } hammerdo
112         
113         tsz {                                           % draw a dark outline
114                 lwd div setlinewidth
115                 0 setgray                               % paint it black
116                 stroke                                  % draw the outline along the path
117         } hammerdo
118 grestore
119 showpage                                                % finished drawing
121 quit
122 %%EOF