summaryrefslogtreecommitdiff
path: root/ipl/gprogs/sier2.icn
diff options
context:
space:
mode:
Diffstat (limited to 'ipl/gprogs/sier2.icn')
-rw-r--r--ipl/gprogs/sier2.icn68
1 files changed, 68 insertions, 0 deletions
diff --git a/ipl/gprogs/sier2.icn b/ipl/gprogs/sier2.icn
new file mode 100644
index 0000000..2ae6ba2
--- /dev/null
+++ b/ipl/gprogs/sier2.icn
@@ -0,0 +1,68 @@
+############################################################################
+#
+# File: sier2.icn
+#
+# Subject: Program to display the Sierpinski fractal
+#
+# Author: Ralph E. Griswold
+#
+# Date: June 24, 1994
+#
+############################################################################
+#
+# This file is in the public domain.
+#
+############################################################################
+#
+# This is a barebones version of a display of the Sierpinski fractal.
+# It has deliberately been left simple and free of options so that the
+# basic idea is clear and so that it can be used as the basis of
+# more capable versions.
+#
+# This program is based on material given in "Chaos, Fractals,
+# and Dynamics", Robert L. Devaney, Addison-Wesley, 1990.
+#
+############################################################################
+#
+# Requires: Version 9 graphics
+#
+############################################################################
+#
+# Links: wopen
+#
+############################################################################
+
+link wopen
+
+procedure main()
+ local extent, x, y, i
+
+ extent := 300
+
+ WOpen("label=sier", "height=" || extent, "width=" || extent) |
+ stop("*** cannot open window")
+
+ x := 20 # The results do not depend on these values
+ y := 150
+
+ every i := 1 to 100000 do {
+ case ?3 of { # Decide what to do at random
+ 1: {
+ x /:= 2
+ y /:= 2
+ }
+ 2: {
+ x /:= 2
+ y := (extent + y) / 2
+ }
+ 3: {
+ x := (extent + x) / 2
+ y := (extent + y) / 2
+ }
+ }
+ if i > 1000 then DrawPoint(x, y) # Wait until attraction
+ }
+
+ Event()
+
+end