summaryrefslogtreecommitdiff
path: root/ipl/gprocs/rpolys.icn
diff options
context:
space:
mode:
Diffstat (limited to 'ipl/gprocs/rpolys.icn')
-rw-r--r--ipl/gprocs/rpolys.icn40
1 files changed, 40 insertions, 0 deletions
diff --git a/ipl/gprocs/rpolys.icn b/ipl/gprocs/rpolys.icn
new file mode 100644
index 0000000..4af3195
--- /dev/null
+++ b/ipl/gprocs/rpolys.icn
@@ -0,0 +1,40 @@
+############################################################################
+#
+# File: rpolys.icn
+#
+# Subject: Procedure to produce traces of regular polygons
+#
+# Author: Ralph E. Griswold
+#
+# Date: March 24, 1999
+#
+############################################################################
+#
+# This file is in the public domain.
+#
+############################################################################
+#
+# Generate points for a regular polygon with the specified number of
+# vertices and radius, centered at cx and cy. The offset angle is theta;
+# default 0.
+#
+############################################################################
+#
+# Links: gobject
+#
+############################################################################
+
+link gobject
+
+procedure rpoly(cx, cy, radius, vertices, theta) #: generate polygon points
+ local incr, i
+
+ incr := 2 * &pi / vertices
+ /theta := 0 # starting angle
+
+ every i := 1 to vertices do {
+ suspend Point(cx + radius * cos(theta), cy + radius * sin(theta))
+ theta +:= incr
+ }
+
+end