Tiny PS function
Web component tiny-ps to display PostScript graphics inside HTML.
- For the complete documentation see https://github.com/bellenuit/tiny-ps
- To try out PostScript use Special:Tiny PS
- To add PostScript to a page, just insert the PostScript code in a tiny-ps function.
Tutorial
You can create any type of vector graphics using PostScript language. PostScript is a very powerful and dynamic language that allows you to add new operators on the fly, like the triangle here.
{{tiny-ps|
/triangle { moveto 100 0 rlineto -50 100 rlineto closepath } def
0.2 setgray 200 100 triangle fill
0.4 setgray 240 140 triangle fill
1.0 setgray 280 180 triangle fill
0.0 setgray 280 180 triangle stroke
showpage}}
Or a more complex one.
{{tiny-ps|
/state { ... } def
/startstate { ... } def
/path { ... } def
/path2 { ... } def
/TGL017 12 selectfont
(start) 100 200 startstate
(number) 200 175 state
(fraction) 200 260 state
(operator) 200 100 state
(0-9-) 100 200 200 175 path
(0-9) 200 175 250 150 250 200 200 175 path2
(.) 200 175 200 260 path
(space) 200 175 170 225 100 225 100 200 path2
(0-9) 200 260 250 235 250 285 200 260 path2
(space) 200 260 175 275 75 250 100 200 path2
(a-z) 100 200 200 100 path
(a-z0-9) 200 100 250 75 250 125 200 100 path2
(space) 200 100 150 125 100 150 100 200 path2
showpage }}
tiny-ps has access to built in fonts. You can add other fonts, if you add the URL to the $rpnFontURLs variable.
{{tiny-ps|
/Nimbus-Sans findfont 20 scalefont setfont
0 280 moveto (Nimbus Sans) show
...
showpage}}