% border.jam
% Rick Beach, July 6, 1982 10:04 am
% Maureen Stone October 14, 1982 10:22 am


% !bh - border unit height
% !bw - border unit width
% !n - number of patterns repeated on each cubic

% touch four points for cubic to draw borderpattern
% <border-width> <border-height> border
(border) {
(!bh) .exch .def
(!bw) .exch .def
(bx) 0 .def conformal
.touch .touch .touch .touch .cubicmapper
!bw !bh .cubicscale
(!al) .getarc .def
(!n) !al !bw .div .cvi .def
(!bw) !al !n .div .def !bw !bh .cubicscale
!n (borderpattern (bx) bx 1 .add .def).cvx .rept}.cvx .def

(colors.jam) .run
20 setmap	%set up the colormap for the standard colors

(honey)(.1 .6 1.0 .hsvcolor).cvx .def
198 .1 .6 1.0 .sethsvmap

% draw a border given the Bezier control points
% <x0 y0 x1 y1 x2 y2 x3 y3> <border-width> <border-height> givenborder
(givenborder) {(!bh) .exch .def (!bw) .exch .def (bx) 0 .def conformal .cubicmapper !bw !bh .cubicscale (!al) .getarc .def
(!n) !al !bw .div .cvi .def
(!bw) !al !n .div .def !bw !bh .cubicscale
!n (borderpattern (bx) bx 1 .add .def).cvx .rept}.cvx .def

(whiteout) {white 0 -.5 move 0 .5 line 1 .5 line 1 -.5 line 0 -.5 line drawarea}.cvx .def

(blackout) {black 0 -.5 move 0 .5 line 1 .5 line 1 -.5 line 0 -.5 line drawarea}.cvx .def

% Greek key
(border1top) {whiteout black 0 0  move 0 .9 line .9 .9 line .9 .2 line .4 .2 line .4 .5 line .6 .5 line .6 .6 line .3 .6 line .3 .1 line 1.0 .1 line 1.0 .0 line .2 .0 line .2 .7 line .7 .7 line .7 .4 line .5 .4 line .5 .3 line .8 .3 line .8 .8 line .1 .8 line .1 .0 line drawarea}.cvx .def

% Greek key
(border1) {white 0 -.5 move 1 -.5 line 1 .4 line 0 .4 line drawarea .blue 0 -.5  move 0 .4 line .9 .4 line .9 -.3 line .4 -.3 line .4 0 line .6 0 line .6 .1 line .3 .1 line .3 -.4 line 1.0 -.4 line 1.0 -.5 line .2 -.5 line .2 .2 line .7 .2 line .7 -.1 line .5 -.1 line .5 -.2 line .8 -.2 line .8 .3 line .1 .3 line .1 -.5 line drawarea}.cvx .def

% candy cane - centred on axis
(border2) {honey 0 -.5 move 0 .5 line 1 .5 line 1 -.5 line 0 -.5 line drawarea
red 0 -.5 move 0 -.45 line 1 -.45 line 1 -.5 line 0 -.5 line drawarea 
red 0 .5 move 0 .45 line 1 .45 line 1 .5 line 0 .5 line drawarea 
red 0 -.5 move  0 .5 line .25 -.5 line 0 -.5 line drawarea
red .225 .5 move .275 .5 line .525 -.5 line .475 -.5 line .225 .5 line drawarea
red .475 .5 move .525 .5 line .775 -.5 line .725 -.5 line .475 .5 line drawarea
red .75 .5 move 1 -.5 line 1 .5 line .75 .5 line drawarea
white 0 .25 move 0 .30 line 1 .30 line 1 .25 line 0 .25 line drawarea }.cvx .def
 
% thin line scroll - on top of axis
(border3) {.red 0 .25 move  .25 .125  .25 0  .125 0 curve 0 0  0 .125 .25 .25 curve 1 .625 1 1 .625 1 curve .25 1 .25 .625 1 .25 curve 0 drawstroke}.cvx .def

% rope border - on top of axis
(border4top) {gray 0 .5 move 0 1 line 1 0 line .5 0 line 0 .5 line drawarea 1 1 move .5 1 line 1 .5 line 1 1 line drawarea black 0 0 move 0 .5 line .5 0 line 0 0 line drawarea .5 0 move 1 0 line 0 drawstroke 0 1 move 1 0 line 1 .5 line .5 1 line 0 1 line drawarea .5 1 move 1 1 line 0 drawstroke}.cvx .def

(border4) {tan 0 0 move 0 .5 line 1 -.5 line .5 -.5 line 0 0 line drawarea 1 .5 move .5 .5 line 1 0 line 1 .5 line drawarea brown 0 -.5 move 0 0 line .5 -.5 line 0 -.5 line drawarea .5 -.5 move 1 -.5 line 0 drawstroke 0 .5 move 1 -.5 line 1 0 line .5 .5 line 0 .5 line drawarea .5 .5 move 1 .5 line 0 drawstroke}.cvx .def

% thin line scroll
(border5) {black 0 .2 move  .2 .1  .2 0  .1 0 curve  0 0  0 .1 .2 .2 curve 1 .6 1 1 .6 1 curve  .2 1 .2 .6 1 .2 curve 0  drawstroke}.cvx .def


% double border - on top of axis (thick is outside if traverse counter-clockwise)
(border6) {darkGreen 0 0 move 1 0 line 1 .5 line 0 .5 line 0 0 line drawarea 0 1 move 1 1 line 1 .75 line 0 .75 line 0 1 line drawarea}.cvx .def

% triple border - centred on axis
(border7) {purple 0 .125 move 1 .125 line 1 -.125 line 0 -.125 line drawarea 0 .5 move 1 .5 line 1 .375 line 0 .375 line drawarea 0 -.5 move 1 -.5 line 1 -.375 line 0 -.375 line drawarea}.cvx .def

% Letraset 941 - on top of axis
(border8) {lightBlue .3 .4 move .3 -.2 line 1 -.2 line 1 .4 line drawarea darkBlue 0 -.5 move
0 .1 line
.3 .4 line
.3 -.2 line
1 -.2 line
.7 -.5 line 0 -.5 line
drawarea}.cvx .def

% Letraset 954 - on top of axis  (dangerous pattern)
(border9) {
.green 
0 zsx 4 zsy move
2 zsx 6 zsy line
3 zsx 5 zsy line
2 zsx 4 zsy line
3 zsx 3 zsy line
2 zsx 2 zsy line
drawarea
2 zsx  8 zsy move
4 zsx 8 zsy line
6 zsx 6 zsy line
5  zsx 5 zsy line
drawarea
2 zsx 0 zsy move
5 zsx 3 zsy line
6 zsx 2 zsy line
4 zsx 0 zsy line 
drawarea
lightGreen
0 zsx 4 zsy move
2 zsx 6 zsy line
4 zsx 4 zsy line
2 zsx 2 zsy line
0 zsx 2 zsy move
2 zsx 0 zsy line
5 zsx 3 zsy line
6 zsx 2 zsy line
6 zsx 6 zsy line
5 zsx 5 zsy line
2 zsx 8 zsy line
0 zsx 6 zsy line
drawarea
}.cvx .def

%leafpattern.jam
(leafpattern) (
lightGreen
% stem
.01 .01 move 1.05 .01 line 1.05 .17 line .01 .17 line .01 .01 line  drawarea 
% leaf
.17 .29 move .29 1.17 .73 .81 1.21 1.17 curve 1.11 .51 .61 .32 .17 .29 curve  drawarea
% leaf
.53 -.11 move .65 -.99 1.09 -.63 1.57 -.99 curve 1.47 -.33 .97 -.14 .53 -.11 curve drawarea).cvx .def

(zsx)(.2 .mul).cvx .def
(zsy)(.1428571 .mul .5 .sub).cvx .def

(dashed1) {whiteout yellow
0 -.5 move 0 .5 line .333 .5 line .333 -.5 line 0 -.5 line drawarea
.666 -.5 move .666 .5 line 1 .5 line 1 -.5 line .666 -.5 line drawarea}.cvx .def

(borderpattern) (border1).cvx .def


(elx) 200 2. .div .def
(ely) 300 2. .div .def
(1-sq2) 2 .5 .exp 1. .sub 4 .mul 3. .div .def

(elipseboundary)
{.newoutline 0 ely .neg .omoveto
1-sq2 elx .mul .neg ely .neg 
elx .neg 1-sq2 ely .mul .neg
elx .neg 0 .ocurveto
elx .neg 1-sq2 ely .mul
1-sq2 elx .mul .neg ely
0 ely .ocurveto}.cvx .def