summaryrefslogtreecommitdiff
path: root/ipl/gprocs/drawcolr.icn
blob: 216f9e211b0192da7f312c7c2d820a5c775f7118 (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
63
64
65
66
67
68
69
############################################################################
#
#	File:     drawcolr.icn
#
#	Subject:  Procedure to display color list
#
#	Author:   Ralph E. Griswold
#
#	Date:     May 2, 2001
#
############################################################################
#
#  This file is in the public domain.
#
############################################################################
#
#  This program displays the colors given in a list.
#
############################################################################
#
#  Requires:  Version 9 graphics  
#
############################################################################
#
#  Links:  graphics
#
############################################################################

$define Cells 16
$define Width 20

link graphics

procedure draw_colors(clist)
   local i, j, k, depth, color, colors

   depth := *clist / Cells
   if *clist % Cells ~= 0 then depth +:= 1

   WClose(\colors)

   colors :=  WOpen("size=" || (Cells * Width) || "," || (depth * Width),
      "bg=black") | {
         Notice("Cannot open window for color map.")
         exit()
         }

   every j := 0 to depth - 1 do
      every i := 0 to Cells - 1 do {
         color := get(clist) | break break
         Fg(colors, color) | {
            Notice("Cannot set foreground to " || image(color) || ".")
            next
            }
         FillRectangle(colors, i * Width + 1, j * Width + 1, Width - 1,
            Width - 1)
         }

   Bg(colors, "dark gray")
   Fg(colors, "black")
   WAttrib(colors, "fillstyle=textured")
   WAttrib(colors, "pattern=checkers")

   every k := i to Width - 1 do			# fill out rest
      FillRectangle(colors, k * Width + 1, j * Width + 1, Width - 1, Width - 1)

   return colors

end