############################################################################
#
#	File:     design2.icn
#
#	Subject:  Program to draw circular design
#
#	Author:   Ralph E. Griswold
#
#	Date:     February 17, 1995
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#  This program draws a design in which i points around a circle are
#  all connected to each other.  The number of points is given as
#  a command-line argument (default 20).  Values larger than 30 produce
#  results that are too dense to be interesting.
#
############################################################################
#
#  Requires:  Version 9 graphics
#
############################################################################
#
#   Links: gobject, joinpair, wopen
#
############################################################################

link gobject
link joinpair
link wopen

procedure main(argl)
   local i, j, k, angle, incr, size, radius, xc, yc, points

   i := integer(argl[1]) | 20

   size := 300
   radius := size / 2
   xc := yc := size / 2

   WOpen("label=mandala", "width=" || size, "height=" || size) |
      stop("*** cannot open window")

   points := list(i)

   angle := 0.0
   incr := 2 * &pi / i

   every j := 1 to i do {
      points[j] := Point(xc + radius * cos(angle), yc + radius * sin(angle))
      angle +:= incr
      }

   joinpair(points, points)

   Event()

end
