postsvg 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rubocop.yml +19 -0
- data/.rubocop_todo.yml +141 -0
- data/Gemfile +15 -0
- data/LICENSE +25 -0
- data/README.adoc +473 -0
- data/Rakefile +10 -0
- data/docs/POSTSCRIPT.adoc +13 -0
- data/docs/postscript/fundamentals.adoc +356 -0
- data/docs/postscript/graphics-model.adoc +406 -0
- data/docs/postscript/implementation-notes.adoc +314 -0
- data/docs/postscript/index.adoc +153 -0
- data/docs/postscript/operators/arithmetic.adoc +461 -0
- data/docs/postscript/operators/control-flow.adoc +230 -0
- data/docs/postscript/operators/dictionary.adoc +191 -0
- data/docs/postscript/operators/graphics-state.adoc +528 -0
- data/docs/postscript/operators/index.adoc +288 -0
- data/docs/postscript/operators/painting.adoc +475 -0
- data/docs/postscript/operators/path-construction.adoc +553 -0
- data/docs/postscript/operators/stack-manipulation.adoc +374 -0
- data/docs/postscript/operators/transformations.adoc +479 -0
- data/docs/postscript/svg-mapping.adoc +369 -0
- data/exe/postsvg +6 -0
- data/lib/postsvg/cli.rb +103 -0
- data/lib/postsvg/colors.rb +33 -0
- data/lib/postsvg/converter.rb +214 -0
- data/lib/postsvg/errors.rb +11 -0
- data/lib/postsvg/graphics_state.rb +158 -0
- data/lib/postsvg/interpreter.rb +891 -0
- data/lib/postsvg/matrix.rb +106 -0
- data/lib/postsvg/parser/postscript_parser.rb +87 -0
- data/lib/postsvg/parser/transform.rb +21 -0
- data/lib/postsvg/parser.rb +18 -0
- data/lib/postsvg/path_builder.rb +101 -0
- data/lib/postsvg/svg_generator.rb +78 -0
- data/lib/postsvg/tokenizer.rb +161 -0
- data/lib/postsvg/version.rb +5 -0
- data/lib/postsvg.rb +78 -0
- data/postsvg.gemspec +38 -0
- data/scripts/regenerate_fixtures.rb +28 -0
- metadata +118 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
= PostScript Operator Reference
|
|
2
|
+
|
|
3
|
+
== General
|
|
4
|
+
|
|
5
|
+
This section provides comprehensive documentation for PostScript operators
|
|
6
|
+
implemented or relevant to the Postsvg library. Operators are organized by
|
|
7
|
+
functional category.
|
|
8
|
+
|
|
9
|
+
== Operator Categories
|
|
10
|
+
|
|
11
|
+
=== link:path-construction.adoc[Path Construction Operators]
|
|
12
|
+
|
|
13
|
+
Operators for building geometric paths:
|
|
14
|
+
|
|
15
|
+
* `newpath` - Initialize empty path
|
|
16
|
+
* `moveto` - Begin new subpath at point
|
|
17
|
+
* `rmoveto` - Begin new subpath at relative point
|
|
18
|
+
* `lineto` - Append straight line segment
|
|
19
|
+
* `rlineto` - Append relative straight line segment
|
|
20
|
+
* `curveto` - Append cubic Bézier curve
|
|
21
|
+
* `rcurveto` - Append relative cubic Bézier curve
|
|
22
|
+
* `arc` - Append circular arc (counterclockwise)
|
|
23
|
+
* `arcn` - Append circular arc (clockwise)
|
|
24
|
+
* `arct` - Append circular arc tangent to two lines
|
|
25
|
+
* `closepath` - Close current subpath
|
|
26
|
+
|
|
27
|
+
=== link:painting.adoc[Painting Operators]
|
|
28
|
+
|
|
29
|
+
Operators for rendering paths:
|
|
30
|
+
|
|
31
|
+
* `stroke` - Stroke current path
|
|
32
|
+
* `fill` - Fill current path (non-zero winding rule)
|
|
33
|
+
* `eofill` - Fill current path (even-odd rule)
|
|
34
|
+
* `clip` - Establish clipping path (non-zero winding rule)
|
|
35
|
+
* `eoclip` - Establish clipping path (even-odd rule)
|
|
36
|
+
* `flattenpath` - Flatten curves to line segments
|
|
37
|
+
* `strokepath` - Convert stroke to filled path
|
|
38
|
+
|
|
39
|
+
=== link:graphics-state.adoc[Graphics State Operators]
|
|
40
|
+
|
|
41
|
+
Operators for managing graphics state:
|
|
42
|
+
|
|
43
|
+
* `gsave` - Save current graphics state
|
|
44
|
+
* `grestore` - Restore saved graphics state
|
|
45
|
+
* `setlinewidth` - Set line width for stroking
|
|
46
|
+
* `setlinecap` - Set line cap style
|
|
47
|
+
* `setlinejoin` - Set line join style
|
|
48
|
+
* `setmiterlimit` - Set miter limit for joins
|
|
49
|
+
* `setdash` - Set dash pattern for lines
|
|
50
|
+
* `setrgbcolor` - Set RGB color
|
|
51
|
+
* `setgray` - Set grayscale color
|
|
52
|
+
* `setcmykcolor` - Set CMYK color
|
|
53
|
+
* `currentlinewidth` - Get current line width
|
|
54
|
+
* `currentrgbcolor` - Get current RGB color
|
|
55
|
+
|
|
56
|
+
=== link:transformations.adoc[Transformation Operators]
|
|
57
|
+
|
|
58
|
+
Operators for coordinate system transformations:
|
|
59
|
+
|
|
60
|
+
* `translate` - Translate origin
|
|
61
|
+
* `scale` - Scale coordinate system
|
|
62
|
+
* `rotate` - Rotate coordinate system
|
|
63
|
+
* `concat` - Concatenate matrix to CTM
|
|
64
|
+
* `matrix` - Create identity matrix
|
|
65
|
+
* `currentmatrix` - Get current transformation matrix
|
|
66
|
+
* `setmatrix` - Set transformation matrix
|
|
67
|
+
* `identmatrix` - Create identity matrix
|
|
68
|
+
* `defaultmatrix` - Get default matrix
|
|
69
|
+
* `transform` - Transform point by matrix
|
|
70
|
+
* `itransform` - Inverse transform point
|
|
71
|
+
|
|
72
|
+
=== link:stack-manipulation.adoc[Stack Manipulation Operators]
|
|
73
|
+
|
|
74
|
+
Operators for working with the operand stack:
|
|
75
|
+
|
|
76
|
+
* `dup` - Duplicate top stack element
|
|
77
|
+
* `pop` - Remove top stack element
|
|
78
|
+
* `exch` - Exchange top two elements
|
|
79
|
+
* `roll` - Roll stack elements
|
|
80
|
+
* `copy` - Copy stack elements
|
|
81
|
+
* `clear` - Clear entire stack
|
|
82
|
+
* `count` - Count stack elements
|
|
83
|
+
* `index` - Access stack element by index
|
|
84
|
+
* `mark` - Push mark on stack
|
|
85
|
+
* `cleartomark` - Clear stack to mark
|
|
86
|
+
* `counttomark` - Count elements to mark
|
|
87
|
+
|
|
88
|
+
=== link:arithmetic.adoc[Arithmetic Operators]
|
|
89
|
+
|
|
90
|
+
Mathematical operators:
|
|
91
|
+
|
|
92
|
+
* `add` - Addition
|
|
93
|
+
* `sub` - Subtraction
|
|
94
|
+
* `mul` - Multiplication
|
|
95
|
+
* `div` - Division (real result)
|
|
96
|
+
* `idiv` - Integer division
|
|
97
|
+
* `mod` - Modulo (remainder)
|
|
98
|
+
* `abs` - Absolute value
|
|
99
|
+
* `neg` - Negation
|
|
100
|
+
* `sqrt` - Square root
|
|
101
|
+
* `sin` - Sine
|
|
102
|
+
* `cos` - Cosine
|
|
103
|
+
* `atan` - Arctangent
|
|
104
|
+
* `exp` - Exponential
|
|
105
|
+
* `ln` - Natural logarithm
|
|
106
|
+
* `log` - Base-10 logarithm
|
|
107
|
+
* `floor` - Round down
|
|
108
|
+
* `ceiling` - Round up
|
|
109
|
+
* `round` - Round to nearest
|
|
110
|
+
* `truncate` - Remove fractional part
|
|
111
|
+
|
|
112
|
+
=== link:control-flow.adoc[Control Flow Operators]
|
|
113
|
+
|
|
114
|
+
Operators for program flow control:
|
|
115
|
+
|
|
116
|
+
* `if` - Conditional execution
|
|
117
|
+
* `ifelse` - Conditional branch
|
|
118
|
+
* `for` - Counted loop
|
|
119
|
+
* `repeat` - Simple loop
|
|
120
|
+
* `loop` - Infinite loop
|
|
121
|
+
* `exit` - Exit loop
|
|
122
|
+
* `forall` - Iterate over array/dictionary
|
|
123
|
+
* `exec` - Execute object
|
|
124
|
+
* `stopped` - Execute with error handling
|
|
125
|
+
* `stop` - Terminate stopped context
|
|
126
|
+
|
|
127
|
+
=== link:dictionary.adoc[Dictionary Operators]
|
|
128
|
+
|
|
129
|
+
Operators for dictionary management:
|
|
130
|
+
|
|
131
|
+
* `dict` - Create dictionary
|
|
132
|
+
* `begin` - Push dictionary on dictionary stack
|
|
133
|
+
* `end` - Pop dictionary from dictionary stack
|
|
134
|
+
* `def` - Define key-value pair
|
|
135
|
+
* `load` - Get value for key
|
|
136
|
+
* `store` - Store value for key
|
|
137
|
+
* `get` - Get dictionary entry
|
|
138
|
+
* `put` - Put dictionary entry
|
|
139
|
+
* `known` - Test if key exists
|
|
140
|
+
* `undef` - Remove definition
|
|
141
|
+
* `where` - Find dictionary containing key
|
|
142
|
+
* `currentdict` - Get current dictionary
|
|
143
|
+
* `countdictstack` - Count dictionary stack depth
|
|
144
|
+
|
|
145
|
+
== Operator Summary Table
|
|
146
|
+
|
|
147
|
+
[cols="1,2,3",options="header"]
|
|
148
|
+
|===
|
|
149
|
+
|Operator |Category |Description
|
|
150
|
+
|
|
151
|
+
|`newpath`
|
|
152
|
+
|Path Construction
|
|
153
|
+
|Initialize empty current path
|
|
154
|
+
|
|
155
|
+
|`moveto`
|
|
156
|
+
|Path Construction
|
|
157
|
+
|Begin new subpath at (x, y)
|
|
158
|
+
|
|
159
|
+
|`lineto`
|
|
160
|
+
|Path Construction
|
|
161
|
+
|Append line to (x, y)
|
|
162
|
+
|
|
163
|
+
|`curveto`
|
|
164
|
+
|Path Construction
|
|
165
|
+
|Append Bézier curve
|
|
166
|
+
|
|
167
|
+
|`closepath`
|
|
168
|
+
|Path Construction
|
|
169
|
+
|Close current subpath
|
|
170
|
+
|
|
171
|
+
|`arc`
|
|
172
|
+
|Path Construction
|
|
173
|
+
|Append counterclockwise circular arc
|
|
174
|
+
|
|
175
|
+
|`stroke`
|
|
176
|
+
|Painting
|
|
177
|
+
|Stroke current path
|
|
178
|
+
|
|
179
|
+
|`fill`
|
|
180
|
+
|Painting
|
|
181
|
+
|Fill current path
|
|
182
|
+
|
|
183
|
+
|`clip`
|
|
184
|
+
|Painting
|
|
185
|
+
|Set clipping path
|
|
186
|
+
|
|
187
|
+
|`gsave`
|
|
188
|
+
|Graphics State
|
|
189
|
+
|Save graphics state
|
|
190
|
+
|
|
191
|
+
|`grestore`
|
|
192
|
+
|Graphics State
|
|
193
|
+
|Restore graphics state
|
|
194
|
+
|
|
195
|
+
|`setlinewidth`
|
|
196
|
+
|Graphics State
|
|
197
|
+
|Set line width
|
|
198
|
+
|
|
199
|
+
|`setrgbcolor`
|
|
200
|
+
|Graphics State
|
|
201
|
+
|Set RGB color
|
|
202
|
+
|
|
203
|
+
|`setgray`
|
|
204
|
+
|Graphics State
|
|
205
|
+
|Set grayscale value
|
|
206
|
+
|
|
207
|
+
|`translate`
|
|
208
|
+
|Transformations
|
|
209
|
+
|Translate coordinate system
|
|
210
|
+
|
|
211
|
+
|`scale`
|
|
212
|
+
|Transformations
|
|
213
|
+
|Scale coordinate system
|
|
214
|
+
|
|
215
|
+
|`rotate`
|
|
216
|
+
|Transformations
|
|
217
|
+
|Rotate coordinate system
|
|
218
|
+
|
|
219
|
+
|`dup`
|
|
220
|
+
|Stack Manipulation
|
|
221
|
+
|Duplicate top element
|
|
222
|
+
|
|
223
|
+
|`pop`
|
|
224
|
+
|Stack Manipulation
|
|
225
|
+
|Remove top element
|
|
226
|
+
|
|
227
|
+
|`exch`
|
|
228
|
+
|Stack Manipulation
|
|
229
|
+
|Exchange top two elements
|
|
230
|
+
|
|
231
|
+
|`add`
|
|
232
|
+
|Arithmetic
|
|
233
|
+
|Add two numbers
|
|
234
|
+
|
|
235
|
+
|`mul`
|
|
236
|
+
|Arithmetic
|
|
237
|
+
|Multiply two numbers
|
|
238
|
+
|
|
239
|
+
|`div`
|
|
240
|
+
|Arithmetic
|
|
241
|
+
|Divide two numbers
|
|
242
|
+
|
|
243
|
+
|`if`
|
|
244
|
+
|Control Flow
|
|
245
|
+
|Conditional execution
|
|
246
|
+
|
|
247
|
+
|`for`
|
|
248
|
+
|Control Flow
|
|
249
|
+
|Counted loop
|
|
250
|
+
|
|
251
|
+
|`def`
|
|
252
|
+
|Dictionary
|
|
253
|
+
|Define variable
|
|
254
|
+
|===
|
|
255
|
+
|
|
256
|
+
== Implementation Status in Postsvg
|
|
257
|
+
|
|
258
|
+
The Postsvg library currently implements the following operators:
|
|
259
|
+
|
|
260
|
+
=== Fully implemented
|
|
261
|
+
|
|
262
|
+
* Path construction: `newpath`, `moveto`, `lineto`, `curveto`, `closepath`
|
|
263
|
+
* Painting: `stroke`, `fill`
|
|
264
|
+
* Graphics state: `gsave`, `grestore`, `setlinewidth`, `setrgbcolor`,
|
|
265
|
+
`setgray`
|
|
266
|
+
* Transformations: `translate`, `scale`, `rotate`
|
|
267
|
+
* Stack manipulation: Basic stack operations
|
|
268
|
+
* Arithmetic: Basic math operations
|
|
269
|
+
|
|
270
|
+
=== Partially implemented
|
|
271
|
+
|
|
272
|
+
* Path construction: `arc`, `arcn` (basic support)
|
|
273
|
+
* Control flow: Limited support for procedures
|
|
274
|
+
|
|
275
|
+
=== Not yet implemented
|
|
276
|
+
|
|
277
|
+
* Text operators: `show`, `findfont`, `setfont`
|
|
278
|
+
* Image operators: `image`, `imagemask`
|
|
279
|
+
* Pattern operators: `makepattern`, `setpattern`
|
|
280
|
+
* Advanced clipping: Full clipping path support
|
|
281
|
+
* Advanced graphics state: `setlinecap`, `setlinejoin`, `setdash`
|
|
282
|
+
|
|
283
|
+
== See Also
|
|
284
|
+
|
|
285
|
+
* link:../fundamentals.adoc[Language Fundamentals]
|
|
286
|
+
* link:../graphics-model.adoc[Graphics Model]
|
|
287
|
+
* link:../implementation-notes.adoc[Implementation Notes]
|
|
288
|
+
* link:../index.adoc[Back to PostScript Quick Reference]
|