summaryrefslogtreecommitdiff
path: root/ipl/gprocs/colrlist.icn
blob: 865cb343e13ac3bc46e2643efdd4e7ff3c52b01c (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
############################################################################
#
#	File:     colrlist.icn
#
#	Subject:  Procedures to produce list of colors
#
#	Author:   Ralph E. Griswold
#
#	Date:     November 24, 1996
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#  colrlist(f) returns a list of the colors given in a file.
#
#  colrplte(p) returns a list of colors for the palette p.
#
############################################################################
#
#  Requires:  Version 9 graphics
#
############################################################################
#
#  Links:  io
#
############################################################################

link io

procedure colrlist(f)			#: list of colors from file
   local input, colors, line

   if f === "-" then input := &input
   else (input := dopen(f)) | fail
   colors := []

   while line := read(input) do
      put(colors, ColorValue(line ? tab(upto('\t') | 0)))

   close(input)

   if *colors = 0 then fail

   return colors

end

procedure colrplte(p)			#: list of colors from palette
   local colors

   colors := []
 
   every put(colors, PaletteColor(p, !PaletteChars(p)))

   if *colors = 0 then fail			# invalid palette

   return colors


end