% graphics.jam
% last changed by Maureen Stone, March 28, 1983 5:11 pm
% last changed by Doug Wyatt, September 15, 1982 8:26 pm
% last changed by Bill Paxton, March 12, 1982 10:03 am

(graphics) 256 .dict .def

graphics .begin
(.setcp) {.setpos}.cvx .def
(.getcp) {.getpos} .cvx .def
(.rmoveto) {.rsetpos}.cvx .def

(twopop){.pop .pop}.cvx .def

(TwoPop) { (twopop) .load .def } .cvx .def

(.reddown) TwoPop
(RedDown) { .reddown } .cvx .def
(CtrlRedDown) TwoPop
(ShiftRedDown) TwoPop
(CtrlShiftRedDown) TwoPop

(.redup) TwoPop
(RedUp) { .redup } .cvx .def
(CtrlRedUp) TwoPop
(ShiftRedUp) TwoPop
(CtrlShiftRedUp) TwoPop

(.yellowdown) TwoPop
(YellowDown) { .yellowdown } .cvx .def
(CtrlYellowDown) TwoPop
(ShiftYellowDown) TwoPop
(CtrlShiftYellowDown) TwoPop

(.yellowup) TwoPop
(YellowUp) { .yellowup } .cvx .def
(CtrlYellowUp) TwoPop
(ShiftYellowUp) TwoPop
(CtrlShiftYellowUp) TwoPop

(.bluedown) TwoPop
(BlueDown) { .bluedown } .cvx .def
(CtrlBlueDown) TwoPop
(ShiftBlueDown) TwoPop
(CtrlShiftBlueDown) TwoPop

(.blueup) TwoPop
(BlueUp) { .blueup } .cvx .def
(CtrlBlueUp) TwoPop
(ShiftBlueUp) TwoPop
(CtrlShiftBlueUp) TwoPop

(.track) TwoPop
(Track) { .track } .cvx .def
(CtrlTrack) TwoPop
(ShiftTrack) TwoPop
(CtrlShiftTrack) TwoPop

(.interrupt){.stop}.cvx .def

(fat){.true .setfat}.cvx .def
(thin){.false .setfat}.cvx .def

(wh){white}0 .aget .def
(gr){gray}0 .aget .def
(bl){black}0 .aget .def

(m){.touch .setcp}.cvx .def
(t){.touch .translate}.cvx .def
(e){.erase}.cvx .def

(box){.touch .touch .drawbox}.cvx .def
(cbox){.touch .touch .clipbox .erase}.cvx .def
(cxbox){.touch .touch .clipxbox .erase}.cvx .def

(traj){.touch .moveto 1 .sub {.touch .lineto}.cvx .rept}.cvx .def

(area){traj .drawarea}.cvx .def
(carea){traj .cliparea .erase}.cvx .def
(cxarea){traj .clipxarea .erase}.cvx .def
(stroke){traj 2 .drawstroke}.cvx .def % round ends

(dot){2 .copy .setpos 2 .copy .drawto}.cvx .def

(spline){{.touch dot .knot}.cvx .rept .spline}.cvx .def
(cspline){{.touch dot .knot}.cvx .rept .cspline}.cvx .def

(curve){spline 2 .drawstroke}.cvx .def % round ends
(ccurve){cspline .close .drawstrokeclosed}.cvx .def

(blob){cspline .drawarea}.cvx .def
(cblob){cspline .cliparea .erase}.cvx .def

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

(fox)(The quick brown fox jumps over the lazy dog.).def
(hi){m (Hello).drawtext}.cvx .def
(his){{.mouse .setcp (Hello).drawtext}.cvx .loop}.cvx .def
(foxes){{.mouse .setpos fox .drawtext}.cvx .loop}.cvx .def
(boxes){{.mouse .translate -25 -25 25 25 .drawbox}.cvx .loop}.cvx .def

(draw){.touch .setpos {.mouse .drawto}.cvx .loop}.cvx .def

(scribble) { (.track) { .drawto } .cvx .def (.reddown) { .setcp } .cvx .def } .cvx .def
(unscribble) { (.track) { .pop .pop } .cvx .def (.reddown) { .pop .pop } .cvx .def } .cvx .def

(grayof) (255.0 .div .grayof).cvx .def
(showr) (1 0 0 .rgbcolor .drawimage).cvx .def
(showg) (0 1 0 .rgbcolor .drawimage).cvx .def
(showb) (0 0 1 .rgbcolor .drawimage).cvx .def
%blue.ais redfile.ais greenfile.ais showimage
(showimage) (0 0 .setcp .true .setopaque showg .false .setopaque showr showb .true .setopaque).cvx .def

%display the 8 bits/pixel colormap
(map8) (.initdc (cindex) 0 .def 16 (onerow -30 16 .mul 30 .translate).cvx .rept).cvx .def
%display the 4 bits/pixel colormap
(map4) ((cindex) 0 .def onerow).cvx .def
(cindex) 0 .def
(onerow) (16 (cindex onebox 30 0 .translate cindex 1 .add (cindex) .exch .store).cvx .rept).cvx .def
(onebox) (.getmapvalue .rgbcolor 0 0 30 30 .drawbox).cvx .def

(e) (.true .setopaque .erase) .cvx .def

%define some color names
% .black, .white, .red, .green, .blue, .magenta, .cyan, .yellow, .gray all defined in TJaMColorImpl
(black){.black}.cvx .def
(white){.white}.cvx .def
(gray){.gray}.cvx .def
(red){.red}.cvx .def
(green){.green}.cvx .def
(blue){.blue}.cvx .def
(magenta){.magenta}.cvx .def
(cyan){.cyan}.cvx .def
(yellow){.yellow}.cvx .def

(darkBrown) {0.075 .5 0.3 .hsvcolor} .cvx  .def
(brown) {0.075 .5 .5 .hsvcolor} .cvx  .def
(tan) {.075 .4 .8 .hsvcolor} .cvx  .def
(darkRed) {0.0 1.0 0.4 .hsvcolor} .cvx  .def
(lightRed) {0 .5 1  .hsvcolor} .cvx  .def
(orange) {0.075 1.0 1.0 .hsvcolor} .cvx  .def
(darkYellow) {.167 1 .5 .hsvcolor} .cvx  .def
(lightYellow) {0.167 .6 1.0 .hsvcolor} .cvx  .def
(darkGreen) {0.333 1.0 0.4 .hsvcolor} .cvx  .def
(lightGreen) {0.333 0.5 1.0 .hsvcolor} .cvx  .def
(darkBlue) {0.67 1.0 0.5 .hsvcolor} .cvx  .def
(lightBlue) {0.67 0.4 1.0 .hsvcolor} .cvx  .def
(purple) {0.776 1 .8 .hsvcolor} .cvx  .def
(violet) {0.776 .5 .8 .hsvcolor} .cvx  .def
(pink) {0.833 0.4 1.0 .hsvcolor} .cvx  .def
(darkGray) {0.0 0.0 0.3 .hsvcolor} .cvx  .def
(lightGray) {0.0 0.0 0.77 .hsvcolor} .cvx  .def