The Ashes
Technology, Science and other news
August 9, 2009
WPS: PostScript and PDF interpreter for HTML 5 canvas
Filed under : General
It would be a pretty cool hack to implement a PostScript/PDF interpreter in JavaScript wouldn’t it? That is exactly what has been done with WPS.
The code takes PS and really groks it so:
JAVASCRIPT:
-
-
/n 10 def
-
/w 25 def
-
-
0 0 n w mul dup .gbox
-
-
4 dict begin
-
0 1 n 1 sub {
-
/i exch def
-
/ii 1 1 n div i mul sub def
-
0 1 n 1 sub {
-
/j exch def
-
/jj 1 1 n div j mul sub def
-
ii jj 0 setrgbcolor
-
w j mul w i mul w w rectfill
-
} for
-
} for
-
end
-
becomes:
And all in ~400 lines of code! Check out the examples….. just awesome!
Tags :
No Comments