-
Notifications
You must be signed in to change notification settings - Fork 0
/
translated.html
197 lines (169 loc) · 13.8 KB
/
translated.html
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<html><meta charset="UTF-8" />
<style>
td{
vertical-align:top;
}
.highlight .hll { background-color: #ffffcc }
.highlight { background: #f8f8f8; }
.highlight .c { color: #408080; font-style: italic } /* Comment */
.highlight .err { border: 1px solid #FF0000 } /* Error */
.highlight .k { color: #008000; font-weight: bold } /* Keyword */
.highlight .o { color: #666666 } /* Operator */
.highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #BC7A00 } /* Comment.Preproc */
.highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */
.highlight .cs { color: #408080; font-style: italic } /* Comment.Special */
.highlight .gd { color: #A00000 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #FF0000 } /* Generic.Error */
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.highlight .gi { color: #00A000 } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.highlight .gt { color: #0044DD } /* Generic.Traceback */
.highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008000 } /* Keyword.Pseudo */
.highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #B00040 } /* Keyword.Type */
.highlight .m { color: #666666 } /* Literal.Number */
.highlight .s { color: #BA2121 } /* Literal.String */
.highlight .na { color: #7D9029 } /* Name.Attribute */
.highlight .nb { color: #008000 } /* Name.Builtin */
.highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.highlight .no { color: #880000 } /* Name.Constant */
.highlight .nd { color: #AA22FF } /* Name.Decorator */
.highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */
.highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0000FF } /* Name.Function */
.highlight .nl { color: #A0A000 } /* Name.Label */
.highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #19177C } /* Name.Variable */
.highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #666666 } /* Literal.Number.Bin */
.highlight .mf { color: #666666 } /* Literal.Number.Float */
.highlight .mh { color: #666666 } /* Literal.Number.Hex */
.highlight .mi { color: #666666 } /* Literal.Number.Integer */
.highlight .mo { color: #666666 } /* Literal.Number.Oct */
.highlight .sb { color: #BA2121 } /* Literal.String.Backtick */
.highlight .sc { color: #BA2121 } /* Literal.String.Char */
.highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.highlight .s2 { color: #BA2121 } /* Literal.String.Double */
.highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */
.highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.highlight .sx { color: #008000 } /* Literal.String.Other */
.highlight .sr { color: #BB6688 } /* Literal.String.Regex */
.highlight .s1 { color: #BA2121 } /* Literal.String.Single */
.highlight .ss { color: #19177C } /* Literal.String.Symbol */
.highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */
.highlight .vc { color: #19177C } /* Name.Variable.Class */
.highlight .vg { color: #19177C } /* Name.Variable.Global */
.highlight .vi { color: #19177C } /* Name.Variable.Instance */
.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */</style><table>
<tr>
<th>PostScript (flag.ps)</th>
<th>Translated to Python syntax</th>
</tr>
<tr><td><div class="highlight"><pre><span class="nv">/numstar</span> <span class="mf">4</span> <span class="nf">def</span>
<span class="nv">/width</span> <span class="mf">720</span> <span class="nf">def</span> <span class="c1">% total flag w,h</span>
<span class="nv">/height</span> <span class="mf">480</span> <span class="nf">def</span>
<span class="nv">/pw</span> <span class="mf">16</span> <span class="nf">def</span> <span class="c1">% pw,ph control size of points</span>
<span class="nv">/ph</span> <span class="mf">60</span> <span class="nf">def</span>
<span class="nv">/npoint</span> <span class="mf">4</span> <span class="nf">def</span> <span class="c1">% num points on a star</span>
<span class="nv">/barheight</span> <span class="mf">80</span> <span class="nf">def</span>
<span class="nv">/starRGB</span> <span class="p">[</span> <span class="mf">1</span> <span class="mf">0</span> <span class="mf">0</span><span class="p">]</span> <span class="nf">def</span>
<span class="nv">/barRGB</span> <span class="p">[</span><span class="mf">.702</span> <span class="mf">.867</span> <span class="mf">.949</span><span class="p">]</span> <span class="nf">def</span> <span class="c1">% #b3ddf2</span>
<span class="nv">/setcolor</span> <span class="p">{</span>
<span class="nf">aload</span> <span class="nf">pop</span> <span class="nf">setrgbcolor</span>
<span class="p">}</span> <span class="nf">def</span>
<span class="nv">/bars</span> <span class="p">{</span>
<span class="mf">0</span> <span class="mf">120</span> <span class="nf">moveto</span>
<span class="nf">width</span> <span class="mf">0</span> <span class="nf">rlineto</span>
<span class="mf">0</span> <span class="mf">360</span> <span class="nf">moveto</span>
<span class="nf">width</span> <span class="mf">0</span> <span class="nf">rlineto</span>
<span class="nf">barheight</span> <span class="nf">setlinewidth</span>
<span class="nf">barRGB</span> <span class="nf">setcolor</span>
<span class="nf">stroke</span>
<span class="p">}</span> <span class="nf">def</span>
<span class="c1">% draw one point for six-pointed star</span>
<span class="nv">/point</span> <span class="p">{</span>
<span class="nf">pw</span> <span class="nf">neg</span> <span class="mf">0</span> <span class="nf">moveto</span>
<span class="nf">pw</span> <span class="nf">ph</span> <span class="nf">rlineto</span>
<span class="nf">pw</span> <span class="nf">ph</span> <span class="nf">neg</span> <span class="nf">rlineto</span>
<span class="p">}</span> <span class="nf">def</span>
<span class="c1">% draw one star</span>
<span class="nv">/star</span> <span class="p">{</span>
<span class="nv">/degrees</span> <span class="mf">360</span> <span class="nf">npoint</span> <span class="nf">div</span> <span class="nf">def</span>
<span class="nf">npoint</span> <span class="p">{</span>
<span class="nf">point</span>
<span class="nf">degrees</span> <span class="nf">rotate</span>
<span class="p">}</span> <span class="nf">repeat</span>
<span class="p">}</span> <span class="nf">def</span>
<span class="nv">/stars</span> <span class="p">{</span>
<span class="c1">% compute horiz distance between stars</span>
<span class="c1">% (equally spaced with pad 10 on both sides)</span>
<span class="c1">% sdist = (width - 20)/(numstar+1)</span>
<span class="nv">/sdist</span> <span class="nf">width</span> <span class="mf">20</span> <span class="nf">sub</span> <span class="nf">numstar</span> <span class="mf">1</span> <span class="nf">add</span> <span class="nf">div</span> <span class="nf">def</span>
<span class="mf">10</span> <span class="nf">sdist</span> <span class="nf">add</span> <span class="nf">height</span> <span class="mf">2</span> <span class="nf">div</span> <span class="nf">translate</span> <span class="c1">% move to first</span>
<span class="nf">numstar</span> <span class="p">{</span>
<span class="nf">star</span>
<span class="nf">sdist</span> <span class="mf">0</span> <span class="nf">translate</span>
<span class="p">}</span> <span class="nf">repeat</span>
<span class="nf">starRGB</span> <span class="nf">setcolor</span>
<span class="nf">fill</span>
<span class="p">}</span> <span class="nf">def</span>
<span class="c1">%---main---</span>
<span class="nf">bars</span>
<span class="nf">stars</span>
</pre></div>
</td><td><div class="highlight"><pre><span class="n">numstar</span> <span class="o">=</span> <span class="mi">4</span>
<span class="n">width</span> <span class="o">=</span> <span class="mi">720</span>
<span class="n">height</span> <span class="o">=</span> <span class="mi">480</span>
<span class="n">pw</span> <span class="o">=</span> <span class="mi">16</span>
<span class="n">ph</span> <span class="o">=</span> <span class="mi">60</span>
<span class="n">npoint</span> <span class="o">=</span> <span class="mi">4</span>
<span class="n">barheight</span> <span class="o">=</span> <span class="mi">80</span>
<span class="n">starRGB</span> <span class="o">=</span> <span class="p">[</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,]</span>
<span class="n">barRGB</span> <span class="o">=</span> <span class="p">[</span><span class="o">.</span><span class="mi">702</span><span class="p">,</span> <span class="o">.</span><span class="mi">867</span><span class="p">,</span> <span class="o">.</span><span class="mi">949</span><span class="p">,]</span>
<span class="k">def</span> <span class="nf">setcolor</span><span class="p">(</span><span class="n">rgb</span><span class="p">):</span>
<span class="n">setrgbcolor</span><span class="p">(</span><span class="o">*</span><span class="n">rgb</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">bars</span><span class="p">():</span>
<span class="n">moveto</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">120</span><span class="p">)</span>
<span class="n">rlineto</span><span class="p">(</span><span class="n">width</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="n">moveto</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">360</span><span class="p">)</span>
<span class="n">rlineto</span><span class="p">(</span><span class="n">width</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="n">setlinewidth</span><span class="p">(</span><span class="n">barheight</span><span class="p">)</span>
<span class="n">setcolor</span><span class="p">(</span><span class="n">barRGB</span><span class="p">)</span>
<span class="n">stroke</span><span class="p">()</span>
<span class="k">def</span> <span class="nf">point</span><span class="p">():</span>
<span class="s">"draw one point for six-pointed star"</span>
<span class="n">moveto</span><span class="p">(</span><span class="o">-</span><span class="n">pw</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="n">rlineto</span><span class="p">(</span><span class="n">pw</span><span class="p">,</span> <span class="n">ph</span><span class="p">)</span>
<span class="n">rlineto</span><span class="p">(</span><span class="n">pw</span><span class="p">,</span> <span class="o">-</span><span class="n">ph</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">star</span><span class="p">():</span>
<span class="s">"draw one star"</span>
<span class="n">degrees</span> <span class="o">=</span> <span class="mi">360</span> <span class="o">/</span> <span class="nb">float</span><span class="p">(</span><span class="n">npoint</span><span class="p">)</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">xrange</span><span class="p">(</span><span class="n">npoint</span><span class="p">):</span>
<span class="n">point</span><span class="p">()</span>
<span class="n">rotate</span><span class="p">(</span><span class="n">degrees</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">stars</span><span class="p">():</span>
<span class="c">#% compute horiz distance between stars</span>
<span class="c">#% (equally spaced with pad 10 on both sides)</span>
<span class="n">sdist</span> <span class="o">=</span> <span class="p">(</span><span class="n">width</span> <span class="o">-</span> <span class="mi">20</span><span class="p">)</span><span class="o">/</span><span class="p">(</span><span class="n">numstar</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span>
<span class="n">translate</span><span class="p">(</span><span class="mi">10</span><span class="o">+</span><span class="n">sdist</span><span class="p">,</span><span class="n">height</span><span class="o">/</span><span class="mi">2</span><span class="p">)</span> <span class="c"># move to first</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">xrange</span><span class="p">(</span><span class="n">numstar</span><span class="p">):</span>
<span class="n">star</span><span class="p">()</span>
<span class="n">translate</span><span class="p">(</span><span class="n">sdist</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
<span class="n">setcolor</span><span class="p">(</span><span class="n">starRGB</span><span class="p">)</span>
<span class="n">fill</span><span class="p">()</span>
<span class="c">#---main---</span>
<span class="n">bars</span><span class="p">()</span>
<span class="n">stars</span><span class="p">()</span>
</pre></div>
</td></tr></table></html>