Files
esoteric/spirograph.ps
2025-10-01 12:56:15 -06:00

55 lines
645 B
PostScript

%!PS
/R {144} def
/r {89} def
/h {55} def
% options
0.1 setlinewidth
2 setlinecap
2 setlinejoin
% set origin on center of page
/in {72 mul} def
8.5 in 2 div
11 in 2 div
translate
% Position x(t), y(t)
/x {
/t exch def
R r sub t cos mul
t 1 R r div sub mul cos h mul
add
% Normalize
144 mul R r sub h add div
} def
/y {
/t exch def
R r sub t sin mul
t 1 R r div sub mul sin h mul
add
% Normalize
144 mul R r sub h add div
} def
% a=mcd{r,R}
/a {r} def
/b {R} def
{
b 0 ne exit if
/x {a b mod} def
/a {b} def
/b {x} def
} loop
% Draw
0 x 0 y moveto
0 1 360 r r mul mul a div
{
dup x exch y lineto
} for
stroke
showpage