%braid.jam
(lx) 0 .def
(rx) (nstrands dx .mul).cvx .def
(nstrands) 3 .def
(tfactor) 1 .def
(dx) 10 .def
(dy) -10 .def
(dy1) (nstrands py .mul 2 .div).cvx .def
(strand) (
lx 0 .moveto
0 dy
rx dy
rx 2 dy .mul .dup (py) .exch .def .curveto
rx py dy1 tfactor .mul .add
lx py dy1 tfactor .mul .add
lx py dy1 2 .mul .add .curveto
.maskstroke
).cvx .def
(braid) ((strand 0 2 dy .mul .translate) .cvx .rept).cvx .def
(nstrands1) (nstrands 1 .add).cvx .def
(cbraidsection) ((color) 1.0 nstrands1 .div .def nstrands1 (
color .makegray .setcolor strand 0 2 dy .mul .translate
(color) color 1.0 nstrands1 .div .add .def
) .cvx .rept).cvx .def
(nswirls) 8 .def
(swirlseq1) (nswirls swirl 0 nswirls dy .mul .translate -1 1 .scale).cvx .def
(swirlseq2) (nswirls swirl 0 nswirls dy .mul 2 .div .translate -1 1 .scale nswirls swirl 0 nswirls dy .mul .translate -1 1 .scale).cvx .def
(seq3) .75 .def
(swirlseq3) (nswirls swirl 0 nswirls dy .mul seq3 .mul .translate -1 1 .scale).cvx .def
(swirlpair) (.pushdc nswirls swirl -1 1 .scale nswirls swirl .popdc).cvx .def
(seq4) 2 .def
(swirlseq4) (swirlpair 0 nswirls dy .mul seq4 .mul .translate 1 -1 .scale swirlpair 1 -1 .scale).cvx .def
(spinangle) 90 .def
(spindy) 0 .def
(swirlspin) (.pushdc 360 spinangle .div (
.pushdc 0 spindy dy .mul .translate nswirls swirl .popdc
spinangle .rotate ).cvx .rept
.popdc).cvx .def
(swirl) (.pushdc (strand1 0 dy .translate) .cvx .rept .popdc).cvx .def
(sw) 3 .def
(swdy) (sw dy .mul).cvx .def
(swdx) (sw dx .mul).cvx .def
(strand1) (
0 0 .moveto
0 swdy tfactor .mul
swdx .neg swdy tfactor .mul
swdx .neg swdy tfactor .mul 2 .mul .curveto
.maskstroke
).cvx .def
(cStrand) (
0 0 .moveto
0 swdy tfactor .mul .neg
swdx .neg 0
swdx .neg swdy tfactor .mul .curveto
.maskstroke
).cvx .def
(sStrand) (
0 0 .moveto
0 swdy tfactor .mul
swdx .neg swdy tfactor .mul
swdx .neg swdy tfactor .mul 2 .mul .curveto
.maskstroke
).cvx .def
(hack1) (.initdc .touch
(nstrands) 4 .def
8 (2 .copy .translate nstrands swirl .initdc (nstrands) nstrands 2 .add .def).cvx .rept
).cvx .def
(hack) (.initdc .touch
(nstrands) 4 .def
8 (2 .copy .translate nstrands swirl .initdc (nstrands) nstrands 2 .add .def).cvx .rept
).cvx .def