diff options
Diffstat (limited to 'ipl/gprogs/spokes.icn')
-rw-r--r-- | ipl/gprogs/spokes.icn | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/ipl/gprogs/spokes.icn b/ipl/gprogs/spokes.icn new file mode 100644 index 0000000..e0c2c81 --- /dev/null +++ b/ipl/gprogs/spokes.icn @@ -0,0 +1,91 @@ +############################################################################ +# +# File: spokes.icn +# +# Subject: Program to draw spokes design +# +# Author: Ralph E. Griswold +# +# Date: September 13, 1997 +# +############################################################################ +# +# This file is in the public domain. +# +############################################################################ +# +# This program draws "spokes" patterns. +# +# The following options are supported: +# +# -g run continuously; ignore user events; default: process user +# events +# -l i limit on number of iterations, default 2 ^ 10 +# -n i maximum number of spokes, default 50 +# -s i size of window (width/height); default 256 +# +############################################################################ +# +# Requires: Version 9 graphics +# +############################################################################ +# +# Links: interact, options, wopen +# +############################################################################ + +link interact +link options +link wopen + +procedure main(args) + local i, j, k, angle, incr, xpoint, ypoint, size, radius, opts + local extent, max, limit, run + + opts := options(args, "gl+n+s+") + + extent := \opts["s"] | 256 + limit := \opts["l"] | (2 ^ 10) + max := \opts["n"] | 50 + run := opts["g"] + + radius := extent / 4 + + WOpen("label=spokes", "width=" || extent, "height=" || extent, + "bg=light gray", "dx=" || (extent / 2), "dy=" || (extent / 2)) | + ExitNotice("Cannot open window.") + + every 1 to limit do { + i := ?max + if i < 4 then i+:= 3 + ?10 # too few doesn't work well ... + angle := 0.0 + incr := 2 * &pi / i + every j := 1 to i do { + spokes(radius * cos(angle), radius * sin(angle), radius, i, angle) + angle +:= incr + } + if /run then repeat case Event() of { + "q": exit() + "s": snapshot() + "n": break + } + WDelay(1000) + EraseArea() + } + +end + +procedure spokes(x, y, r, i, angle) + local incr, j + + incr := 2 * &pi / i + + every j := 1 to i do { + DrawLine(x, y, x + r * cos(angle), y + r * sin(angle)) + angle +:= incr + } + + return + +end + |