wps

PostScript for the Web
git clone https://logand.com/git/wps.git/
Log | Files | Refs | LICENSE

commit 975def2ab8a1412831ffe0424df7cb386b2e3094
parent 019ae71391e6e2970b254c2d4f9e214325ff74d0
Author: Tomas Hlavaty <tom@logand.com>
Date:   Wed, 28 Aug 2019 15:13:12 +0200

add index.html dependencies

Diffstat:
Asandbox.html | 508+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atiger.png | 0
2 files changed, 508 insertions(+), 0 deletions(-)

diff --git a/sandbox.html b/sandbox.html @@ -0,0 +1,508 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" +lang="en" xml:lang="en"> +<head> +<title>WPS Sandbox</title> +<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/> +<meta name="generator" content="Org-mode"/> +<meta name="generated" content="2009-07-21 11:33:22 CEST"/> +<meta name="author" content="Tomas Hlavaty"/> +<meta name="description" content="PostScript and PDF interpreter for HTML 5 canvas"/> +<meta name="keywords" content="PostScript, PDF, interpreter, HTML 5, canvas, JavaScript"/> + +<link rel="stylesheet" href="../../logand.css" type="text/css"/> +<link rel="icon" href="../../favicon.ico" type="image/x-icon"/> +<link rel="shortcut icon" href="../../favicon.ico" type="image/x-icon"/> +<script type="text/javascript"> +<!--/*--><![CDATA[/*><!--*/ + function CodeHighlightOn(elem, id) + { + var target = document.getElementById(id); + if(null != target) { + elem.cacheClassElem = elem.className; + elem.cacheClassTarget = target.className; + target.className = "code-highlighted"; + elem.className = "code-highlighted"; + } + } + function CodeHighlightOff(elem, id) + { + var target = document.getElementById(id); + if(elem.cacheClassElem) + elem.className = elem.cacheClassElem; + if(elem.cacheClassTarget) + target.className = elem.cacheClassTarget; + } +/*]]>*///--> +</script> +</head> +<body> +<div id="content"> + +<div id="menu"> +<div> +<table width="100%"> +<tr> +<td> +<table> +<tr> +<td><img src="../../logand1.png" alt="logo"/></td> +<td align="center"> +<img src="../../logand2.png" alt="url"/><br/> +web &amp; software development +</td> +</tr> +</table> +</td> +<td class="menu3"> +<span> +<a href="../../index.html">Home</a> +| <a href="../../sw/index.html">Software</a> +| <a href="../../blog/index.html">Blog</a> +| <a href="../../contact.html">Contact</a> +</span> +</td> +</tr> +</table> +</div> +</div> +<div> + + +<div id="outline-container-1" class="outline-1"> +<h1 id="sec-1">WPS sandbox </h1> +<div class="outline-text-1" id="text-1"> + + + + +<div id="wps" style="display:none"> + +<pre class="src src-text"> +%%% (c) 2009 Tomas Hlavaty + +currentdict/systemdict currentdict put +systemdict/{/mark cvx put +systemdict/[/mark cvx put +systemdict/] +/counttomark cvx +/array cvx +/astore cvx +/exch cvx +/pop cvx +5 array astore cvx put +systemdict/}/] cvx/cvx cvx 2 array astore cvx put +systemdict/def{currentdict 2 index 2 index put pop pop}put + +/maxlength 1000 def % TODO +/.bdef{bind def}bind def +/.xdef{exch def}.bdef +/dup{0 index}.bdef +/load{dup where pop exch get}.bdef +/.ldef{load def}.bdef +/if{{}ifelse}.bdef +/cleartomark{array pop}.bdef +/known{exch begin where{currentdict eq}{false}if end}.bdef +/store{1 index where{3 1 roll put}{def}ifelse}.bdef +/not{{false}{true}ifelse}.bdef +/.logand{{{true}{false}ifelse}{pop false}ifelse}.bdef +/and/.logand .ldef % TODO numeric and +/.logor{{pop true}{{true}{false}ifelse}ifelse}.bdef +/or/.logor .ldef % TODO numeric or +/ne{eq not}.bdef +/ge{lt not}.bdef +/le{1 index 1 index eq 3 1 roll lt or}.bdef +/gt{le not}.bdef +/.repeat{1 1 4 2 roll for}.bdef + +%% math + +/floor{.math(floor)1 .call}.bdef + +/neg{0 exch sub}.bdef +/add{neg sub}.bdef +/idiv{div floor}.bdef + +/abs{.math(abs)1 .call}.bdef +/.acos{.math(acos)1 .call}.bdef +/.asin{.math(asin)1 .call}.bdef +/atan{exch .math(atan)1 .call}.bdef +/.atan2{.math(atan2)2 .call}.bdef +/ceiling{.math(ceil)1 .call}.bdef +/cos{.math(cos)1 .call}.bdef +/.exp{.math(exp)1 .call}.bdef +/log{.math(log)1 .call}.bdef +/.max{.math(max)2 .call}.bdef +/.min{.math(min)2 .call}.bdef +/.pow{.math(pow)2 .call}.bdef +/.random{.math(random)0 .call}.bdef +/rand{.random}.bdef % TODO follow spec +/round{.math(round)1 .call}.bdef +/sin{.math(sin)1 .call}.bdef +/sqrt{.math(sqrt)1 .call}.bdef +/.tan{.math(tan)1 .call}.bdef +/truncate{.math(truncate)1 .call}.bdef % TODO Math.truncate does not exist! + +/.e{.math(E)get}.bdef +/.ln2{.math(LN2)get}.bdef +/.ln10{.math(LN10)get}.bdef +/.log2e{.math(LOG2E)get}.bdef +/.log10e{.math(LOG10E)get}.bdef +/.pi{.math(PI)get}.bdef +/.sqrt1_2{.math(SQRT1_2)get}.bdef +/.sqrt2{.math(SQRT2)get}.bdef + +%% html + +/.setTimeout{.window(setTimeout)2 .call}.bdef % cb ms -- id +/.clearTimeout{.window(clearTimeout)1 .call pop}.bdef % id -- +/.setInterval{.window(setInterval)2 .call}.bdef % cb ms -- id +/.clearInterval{.window(clearInterval)1 .call pop}.bdef % id -- +/.document{.window(document)get}.bdef % -- document +/.getElementById{.document(getElementById)1 .call}.bdef % id -- w +/.hook{put}.bdef % e k cb -- + +%% canvas + +/.setGc{.getElementById(2d)exch(getContext)1 .call/.$gc .xdef}.bdef +/.gc{/.$gc load}.bdef +/.gget{.gc exch get}.bdef +/.gput{.gc 3 1 roll exch put}.bdef +/.gcall0{.gc 3 1 roll .call pop}.bdef +/.gcall1{.gc 3 1 roll .call}.bdef +/.gcanvas{(canvas).gget}.bdef +/.gdim{.gcanvas exch(height)exch put .gcanvas exch(width)exch put}.bdef +/.gbox{.gdim pop pop}.bdef % TODO compute properly + +/.save{(save)0 .gcall0}.bdef +/.restore{(restore)0 .gcall0}.bdef +/.scale{(scale)2 .gcall0}.bdef +/.rotate{(rotate)1 .gcall0}.bdef +/.translate{(translate)2 .gcall0}.bdef +/.transform{(transform)6 .gcall0}.bdef +/.setTransform{(setTransform)6 .gcall0}.bdef +/.createLinearGradient{(createLinearGradient)4 .gcall1}.bdef +/.createRadialGradient{(createRadialGradient)6 .gcall1}.bdef +/.createPattern{(createPattern)2 .gcall1}.bdef +/.clearRect{(clearRect)4 .gcall0}.bdef +/.fillRect{(fillRect)4 .gcall0}.bdef +/.strokeRect{(strokeRect)4 .gcall0}.bdef +/.beginPath{(beginPath)0 .gcall0}.bdef +/.closePath{(closePath)0 .gcall0}.bdef +/.moveTo{(moveTo)2 .gcall0}.bdef +/.lineTo{(lineTo)2 .gcall0}.bdef +/.quadraticCurveTo{(quadraticCurveTo)4 .gcall0}.bdef +/.bezierCurveTo{(bezierCurveTo)6 .gcall0}.bdef +/.arcTo{(arcTo)5 .gcall0}.bdef +/.rect{(rect)4 .gcall0}.bdef +/.arc{(arc)6 .gcall0}.bdef +/.fill{(fill)0 .gcall0}.bdef +/.stroke{(stroke)0 .gcall0}.bdef +/.clip{(clip)0 .gcall0}.bdef +/.isPointInPath{(isPointInPath)2 .gcall1}.bdef +/.fillText{(fillText)4 .gcall0}.bdef +/.fillText{}.bdef % TODO not working in Firefox +/.strokeText{(strokeText)4 .gcall0}.bdef +/.strokeText{}.bdef % TODO not working in Firefox +/.measureText{(measureText)1 .gcall1}.bdef +/.drawImage1{(drawImage1)5 .gcall0}.bdef +/.drawImage2{(drawImage2)9 .gcall0}.bdef +/.createImageData1{(createImageData1)1 .gcall1}.bdef +/.createImageData2{(createImageData2)2 .gcall1}.bdef +/.getImageData{(getImageData)4 .gcall1}.bdef +/.putImageData{(putImageData)7 .gcall0}.bdef + +/.getGlobalAlpha{(globalAlpha).gget}.bdef +/.getGlobalCompositeOperation{(globalCompositeOperation).gget}.bdef +/.getStrokeStyle{(strokeStyle).gget}.bdef +/.getFillStyle{(fillStyle).gget}.bdef +/.getLineWidth{(lineWidth).gget}.bdef +/.getLineCap{(lineCap).gget}.bdef +/.getLineJoin{(lineJoin).gget}.bdef +/.getMiterLimit{(miterLimit).gget}.bdef +/.getShadowOffsetX{(shadowOffsetX).gget}.bdef +/.getShadowOffsetY{(shadowOffsetY).gget}.bdef +/.getShadowBlur{(shadowBlur).gget}.bdef +/.getShadowColor{(shadowColor).gget}.bdef +/.getFont{(font).gget}.bdef +/.getTextAlign{(textAlign).gget}.bdef +/.getTextBaseline{(textBaseline).gget}.bdef + +/.setGlobalAlpha{(globalAlpha).gput}.bdef +/.setGlobalCompositeOperation{(globalCompositeOperation).gput}.bdef +/.setStrokeStyle{(strokeStyle).gput}.bdef +/.setFillStyle{(fillStyle).gput}.bdef +/.setLineWidth{(lineWidth).gput}.bdef +/.setLineCap{(lineCap).gput}.bdef +/.setLineJoin{(lineJoin).gput}.bdef +/.setLineCap{pop}.bdef % TODO remove this later (Firefox throws) +/.setLineJoin{pop}.bdef % TODO remove this later (Firefox throws) +/.setMiterLimit{(miterLimit).gput}.bdef +/.setShadowOffsetX{(shadowOffsetX).gput}.bdef +/.setShadowOffsetY{(shadowOffsetY).gput}.bdef +/.setShadowBlur{(shadowBlur).gput}.bdef +/.setShadowColor{(shadowColor).gput}.bdef +/.setFont{(font).gput}.bdef +/.setTextAlign{(textAlign).gput}.bdef +/.setTextBaseline{(textBaseline).gput}.bdef + +%% PostScript + +/.deg2rad{.pi 180 div mul}.bdef +/.rad2deg{180 .pi div mul}.bdef + +/.$cx 0 def +/.$cy 0 def +/.$px 0 def +/.$py 0 def +/.setPoint{/.$cy .xdef/.$cx .xdef}.bdef +/.setPath{/.$py .xdef/.$px .xdef}.bdef +/currentpoint{/.$cx load /.$cy load}.bdef +/.getPath{/.$px load /.$py load}.bdef + +/identmatrix{pop [1 0 0 1 0 0]}.bdef % TODO fill +/matrix{6 array identmatrix}.bdef +/setmatrix{/.$tm .xdef}.bdef +/defaultmatrix{pop matrix}.bdef % TODO fill +/initmatrix{matrix defaultmatrix setmatrix}.bdef +/currentmatrix{pop /.$tm load}.bdef % TODO fill +initmatrix + +/.getTmd{/.$tmd load}.bdef +/.setTmd{/.$tmd .xdef}.bdef +/.resetTmd{matrix .setTmd}.bdef +.resetTmd + +/.update{ % m -- + currentpoint 2 index % m .$cx .$cy m + .xy .setPoint % m + dup .getTmd exch .mmul .setTmd % (.$tmd x m) + dup currentmatrix exch .mmul setmatrix % = .$tm x m +}.bdef + +/transform{dup type(arraytype)ne{.getTmd}if .xy}.bdef +/itransform{dup type(arraytype)ne{.getTmd}if .minv .xy}.bdef + +/.scaleM{0 0 3 2 roll 0 0 6 array astore}.bdef % x y -- [x 0 0 y 0 0] +/.scale3{pop .scaleM}.bdef +/.scale2{2 copy .scaleM .update .scale}.bdef +/scale{dup type(arraytype)eq{.scale3}{.scale2}ifelse}.bdef + +/.translateM{1 0 0 1 6 4 roll 6 array astore}.bdef % x y -- [1 0 0 1 x y] +/.translate3{pop .translateM}.bdef +/.translate2{2 copy .translateM .update .translate}.bdef +/translate{dup type(arraytype)eq{.translate3}{.translate2}ifelse}.bdef + +/.rotateM{dup cos exch sin dup neg 2 index 0 0 6 array astore}.bdef % a -- [c s -s c 0 0] +/.rotate2{pop .deg2rad .rotateM}.bdef +/.rotate1{.deg2rad dup .rotateM .update .rotate}.bdef +/rotate{dup type(arraytype)eq{.rotate2}{.rotate1}ifelse}.bdef + +%matrix concat &#8211; Replace CTM by matrix &#180; CTM +%matrix1 matrix2 matrix3 concatmatrix matrix3 Fill matrix3 with matrix1 &#180; matrix2 + +%dx dy dtransform dx&#162; dy&#162; Transform distance (dx, dy) by CTM +%dx dy matrix dtransform dx&#162; dy&#162; Transform distance (dx, dy) by matrix + +%dx&#162; dy&#162; idtransform dx dy Perform inverse transform of distance (dx&#162;, dy&#162;) by CTM +%dx&#162; dy&#162; matrix idtransform dx dy Perform inverse transform of distance (dx&#162;, dy&#162;) by matrix + +%matrix1 matrix2 invertmatrix matrix2 Fill matrix2 with inverse of matrix1 + +/gsave{.save}.bdef +/grestore{.restore}.bdef +/clip{.clip}.bdef +/rectclip{.clearRect}.bdef +/rectfill{.fillRect}.bdef +/rectstroke{.strokeRect}.bdef +/newpath{.beginPath}.bdef +/closepath{.closePath}.bdef +/moveto{2 copy .setPoint 2 copy .setPath .resetTmd .moveTo}.bdef +/lineto{2 copy .setPoint 2 copy .setPath .resetTmd .lineTo}.bdef +/arcto{.arcTo}.bdef + +/setlinewidth{.setLineWidth}.bdef +/setlinecap{.setLineCap}.bdef % TODO +/setlinejoin{.setLineJoin}.bdef % TODO +/setmiterlimit{.setMiterLimit}.bdef + +/currentlinewidth{.getLineWidth}.bdef +/currentlinecap{&lt;&lt;/butt 0/round 1/square 2&gt;&gt; .getLineCap get}.bdef +/currentlinejoin{&lt;&lt;/miter 0/round 1/bevel 2&gt;&gt; .getLineJoin get}.bdef +/currentmiterlimit{.getMiterLimit}.bdef + +/setgray{255 mul dup dup .rgb dup .setStrokeStyle .setFillStyle}.bdef +/setrgbcolor{3{255 mul round 3 1 roll}repeat .rgb dup .setStrokeStyle .setFillStyle}.bdef +/setcmykcolor{setrgbcolor pop}.bdef % TODO +/sethsbcolor{setrgbcolor}.bdef % TODO +/clippath{0 0 .gcanvas(width)get .gcanvas(height)get .rect}.bdef % TODO +/show{currentpoint 3 2 roll 3 copy .fillText .strokeText}.bdef % TODO + +/rlineto{.getTmd .xy /.$py load add exch /.$px load add exch .getTmd .minv .xy lineto}.bdef +/curveto{2 copy .setPoint 2 copy .setPath .resetTmd .bezierCurveTo}.bdef + +/currentflat{42}.bdef % TODO +/setflat{pop}.bdef % TODO + +/arc{.deg2rad exch .deg2rad exch true .arc}.bdef % TODO currentpoint +/arcn{.deg2rad exch .deg2rad exch false .arc}.bdef % TODO currentpoint + +/fill{.fill newpath currentpoint .moveTo}.bdef % TODO + +/setdash{pop pop}.bdef % TODO + +/stroke{.stroke newpath currentpoint .moveTo}.bdef + +/showpage{}.bdef % TODO +/grestoreall{}.bdef % TODO +/readonly{}.bdef % TODO +/currentfile{(url?)}.bdef % TODO +/eexec{pop}.bdef % TODO +/findfont{}.bdef % TODO +/scalefont{pop}.bdef % TODO +/setfont{pop}.bdef % TODO C.font = N + "pt " + F.V; +/stopped{}.bdef % TODO +/loop{}.bdef % TODO !!! +/string{}.bdef % TODO +/cvi{}.bdef % TODO +/pathbbox{}.bdef % TODO +/urx{}.bdef % TODO +/ury{}.bdef % TODO +/llx{}.bdef % TODO +/lly{}.bdef % TODO +/pagewidth{}.bdef % TODO +/pageheight{}.bdef % TODO +/inwidth{}.bdef % TODO +/inheight{}.bdef % TODO +/usertime{}.bdef % TODO +/srand{}.bdef % TODO + +%% PDF + +/w{setlinewidth}.bdef +/J{setlinecap}.bdef % TODO +/j{setlinejoin}.bdef % TODO +/M{setmiterlimit}.bdef +/d{setdash}.bdef % TODO +/ri{}.bdef % TODO +/i{1 .min setflat}.bdef +/gs{}.bdef % TODO +/q{gsave}.bdef +/Q{grestore}.bdef +/cm{.transform}.bdef +/m{newpath moveto}.bdef % TODO only if not m previously +/l{lineto}.bdef +/c{.bezierCurveTo}.bdef +/v{currentpoint 6 2 roll c}.bdef +/y{2 copy c}.bdef +/h{closepath}.bdef % TODO +/re{.rect}.bdef % TODO really, or x y m , x+w y l , x+w y+h l , x y+h l , h +/S{stroke}.bdef +/s{h S}.bdef +/f{fill}.bdef % TODO +/F{f}.bdef +/f*{}.bdef % TODO +/B{f S}.bdef +/B*{f* S}.bdef +/b{h B}.bdef +/b*{h B*}.bdef +/n{}.bdef % TODO +/W{clip}.bdef % TODO +/W*{clip}.bdef % TODO +/BT{}.bdef % TODO +/ET{}.bdef % TODO +/Tc{}.bdef % TODO +/Tw{}.bdef % TODO +/Tz{}.bdef % TODO +/TL{}.bdef % TODO +/Tf{setfont}.bdef % TODO +/Tr{}.bdef % TODO +/Ts{}.bdef % TODO +/Td{translate 0 0 moveto}.bdef +/TD{}.bdef % TODO +/Tm{}.bdef % TODO +/T*{}.bdef % TODO +/Tj{show}.bdef % TODO +/TJ{}.bdef % TODO +/'{}.bdef % TODO +/"{}.bdef % TODO +/d0{}.bdef % TODO +/d1{}.bdef % TODO +/CS{}.bdef % TODO +/cs{}.bdef % TODO +%/SC/setcolor .ldef +/SCN{}.bdef % TODO +%/sc/setcolor .ldef +/scn{}.bdef % TODO +/G{}.bdef % TODO +/g{}.bdef % TODO +/RG{}.bdef % TODO +/rg{setrgbcolor}.bdef % TODO +/K{}.bdef % TODO +/k{}.bdef % TODO +/sh{}.bdef % TODO +/BI{}.bdef % TODO +/ID{}.bdef % TODO +/EI{}.bdef % TODO +/Do{}.bdef % TODO +/MP{}.bdef % TODO +/DP{}.bdef % TODO +/BMC{}.bdef % TODO +/BDC{}.bdef % TODO +/EMC{}.bdef % TODO +/BX{}.bdef % TODO +/EX{}.bdef % TODO + +%% finish + +false .strictBind + +/userdict 1000 dict def +userdict begin +</pre> + + + +</div> + +<style>canvas {width:12em;height:12em;border:1px dashed black}</style> +<script type="text/javascript" src="wps.js"></script> +<script> +function $(Id) {return document.getElementById(Id);} +function $$(Id) {return $(Id).textContent;} +</script> +<canvas id="xsandbox"></canvas> +<p>Sandbox:</p> +<p> +<textarea id="sandbox" style="width:100%" rows="18"> +/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 +</textarea> +</p> +<script> +function sandbox() {(new Wps).parse($$("wps"), "(xsandbox) .setGc", $("sandbox").value);} +</script> +<button onclick="javascript:sandbox();">Run</button> code from sandbox. +</div> +</div> +</div> +</div> +</body> +</html> diff --git a/tiger.png b/tiger.png Binary files differ.