commit 11753de77ee6a83ceec0565a028263edf6102207 Author: PedroEdiaz Date: Wed Oct 1 12:56:15 2025 -0600 Add: spirograph.ps diff --git a/spirograph.ps b/spirograph.ps new file mode 100644 index 0000000..8d1893b --- /dev/null +++ b/spirograph.ps @@ -0,0 +1,54 @@ +%!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