summaryrefslogtreecommitdiff
path: root/ipl/gprogs/wheel.icn
blob: 8d1eec10727767e53a5bb2106d3931ad90c027d6 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
############################################################################
#
#	File:     wheel.icn
#
#	Subject:  Program to show wheel of colors
#
#	Author:   Gregg M. Townsend
#
#	Date:     November 14, 1994
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#     wheel displays a disk made of randomly colored sectors.  In addition
#  to the usual window options, the number of sectors may be given.
#
############################################################################
#
#  Requires:  Version 9 graphics
#
############################################################################
#
#  Links: graphics, random
#
############################################################################

link graphics
link random

$define BevelWidth 2
$define WindowMargin 10

procedure main(args)
   local win, gc, w, h, m, a, da, n, ov, i, t

   win := Window("size=400,400", args)
   n := integer(args[1]) | 18

   m := WindowMargin
   w := WAttrib("width") - 2 * m
   h := WAttrib("height") - 2 * m
   randomize()

   gc := []
   every 1 to n do
      put(gc, Shade(Clone(win), ?65535 || "," || ?65535 || "," || ?65535))
   if *gc = 0 then
      stop("can't allocate any colors")
   if n >:= *gc then
      write(&errout, "using only ", n, " colors")

   da := 2 * &pi / n			# change in angle
   a := -&pi / 2 - da			# current angle
   ov := &pi / 1000			# small overlap

   every i := 1 to n do
      FillArc(gc[i], m, m, w, h, a +:= da, da + ov)
   WDone(win)
end