summaryrefslogtreecommitdiff
path: root/ipl/gprocs/spirals.icn
blob: 52bc7cc5715f01f4cf3ee275365020fe8efc5d31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
############################################################################
#
#	File:     spirals.icn
#
#	Subject:  Procedure to produce traces of fractal stars
#
#	Author:   Ralph E. Griswold
#
#	Date:     May 2, 2001
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#  Draw spiral with n segments and t rotations, starting at (x,y).
#  The extent determines the size of the drawing.
#
#  The eccentricity is e (1 gives circle) and the reduction factor is r.
#  The angular increment is incr and the y scaling factor is yfact.
#
############################################################################
#
#  Links:  gobject, numbers
#
############################################################################

link gobject
link numbers

procedure spiral(x, y, extent, n, t, e, r, incr, yfact)
   local i, c, s, angle, redrad, x1, y1

   incr := dtor(incr)

   every i := 0 to n do {
      redrad := r ^ div(i, n)
      angle := (incr * i) / n
      x1 := redrad * cos(t * angle)
      y1 := redrad * e * sin(t * angle)
      c := cos(angle)
      s := sin(angle)
      suspend Point(x + extent / 2 * (1 + x1 * c - y1 * s),
         y + extent / 2 * yfact * (1 + x1 * s + y1 * c))
      }

end