(/setview)
(.touch .touch .touch .touch viewport).cvx .def

(viewport)
(4 .copy 4 .copy .setclip .erase .drawbox .setview ).cvx .def

(dot)(2 .copy .dot).cvx .def

(path)((.touch .enterpoint).cvx .rept .newboundary).cvx .def
(rect)(.touch .touch .enterrect).cvx .def

(clip)(.startpath path .cliparea .erase).cvx .def
(cclip)(.startpath path .clippedcliparea .erase).cvx .def
(clips)(.startpath (rect).cvx .rept .cliparea .erase).cvx .def
(rclips)(.startpath (.touch .touch .enterrect).cvx .rept .cliparea .erase).cvx .def

(poly)(.touch dot .moveto 1 .sub (.touch .drawto) .cvx .rept) .cvx .def

(area)(.startpath (.touch dot .enterpoint) .cvx .rept .drawarea) .cvx .def

(spray)(.touch .translate .pushdc 120 (0 0 .moveto 1000 0 .drawto 3 .rotate) .cvx .rept .popdc) .cvx .def

(spline)(.dup (.touch dot 3 -1 .roll) .cvx .rept .enterspline).cvx .def

(cspline)(.dup (.touch dot 3 -1 .roll) .cvx .rept .entercspline).cvx .def

(blob)(.startpath cspline .drawarea).cvx .def

(cblob)(.startpath cspline .cliparea .erase).cvx .def

(gencircle)(1. 0 .moveto .dup 360. .exch .div 0 3 -1 .roll(2 .copy .pop .add .dup .dup .cos .exch .sin .drawto) .cvx .rept .pop .pop) .cvx .def

(tp) 4 .array .def

(#)(.load).cvx .def

(text)
( text  This command accepts an initial position, a leading value and a 
string on the operand stack. The text is broken into parts that are separated
by carraige returns. These parts are displayed using the x part of the
position as the left margin.)
[ tp 0 3 -1 (.roll)# (.aput)# tp 3 3 -1 (.roll)# (.aput)#  tp 2 3 -1 (.roll)# (.aput)# tp 1 3 -1 (.roll)# (.aput)# tp 0 (.aget)# (
) [ tp 1 (.aget)# tp 2 (.aget)# (.moveto).cvx (.search)# [ (.drawstring).cvx
tp 2 tp 2 (.aget)# tp 3 (.aget)# (.sub)# (.aput)# ] [ (.drawstring).cvx
(.exit)#  ] (.ifelse)# (.cvx)# (.exec)# ] (.cvx)# (.loop)# ] /xdef


(zoom)
("zoom" allows the user to look (temporarily) at a portion of the screen.  the first four .touches define a mapping and repaint the given display object in the new mapping. the last touch removes the window and repaints the original object.)
((!f).exch .def !f lookat .touch .pop .pop !f refresh)/xdef
 
(lookat)(.pushdc .touch .touch .touch .touch  4 .copy 12 4 .roll viewport 5 -1 .roll .drawob .popdc).cvx .def

(refresh)(.pushdc  5 1 .roll .setclip .erase .drawob .popdc).cvx .def

(paint) 0 .def
(replace) 1 .def
(invert) 2 .def
(erase) 3 .def

(gray0) -1 .def
(gray1) 32767 .def
(gray2) 32735 .def
(gray3) 24543 .def
(gray4) 24415 .def
(gray5) 23391 .def
(gray6) 23390 .def
(gray7) 23134 .def
(gray8) 23130 .def
(gray9) 6746 .def
(gray10) 6730 .def
(gray11) 2634 .def
(gray12) 2570 .def
(gray13) 2058 .def
(gray14) 2050 .def
(gray15) 2 .def
(gray16) 0 .def
(black) gray0 .def
(white) gray16 .def
(checked) 13260 .def

(areatest)((.mouse .translate star .drawob).cvx .loop).cvx .def
(obtest)((.mouse .translate .dup .drawob 1 .rotate).cvx .loop).cvx .def
(linetest)(.touch .translate (0 0 .moveto .mouse .drawto).cvx .loop).cvx .def
(fox)(The quick brown fox jumps over the lazy dog.).def
(texttest)((.mouse .moveto fox .drawstring).cvx .loop).cvx .def
(stest)((.mouse .moveto .dup .drawstring).cvx .loop).cvx .def
(ctest)((.mouse .moveto .dup .drawchars).cvx .loop).cvx .def

(boxarea)(.initboxer area .stopboxer showbox).cvx .def
(showbox)(.pushdc invert .paint black .texture
 .startpath 4 (.enterpoint).cvx .rept .drawarea .popdc).cvx .def
(box)(.touch .touch .drawboxarea).cvx .def
(rect)(.touch .touch .enterrect).cvx .def
(bkg)(.pushdc gray8 .texture replace .paint .drawscreenarea .popdc).cvx .def
(init)(.initdc bkg).cvx .def
(t)(.touch .translate 0 0 .moveto).cvx .def
(e)(.erase).cvx .def