summaryrefslogtreecommitdiff
path: root/ipl/gprogs/plat.icn
blob: 881a9b2179f3fc6a0b6b49da281ce4519f619413 (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
############################################################################
#
#	File:     plat.icn
#
#	Subject:  Program to create image file with specified colors
#
#	Author:   Ralph E. Griswold
#
#	Date:     January 6, 1995
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#  This program produces image files from color lists, in which the
#  image file contains one pixel for each color.  The image files are
#  16x16 pixels.  If a color list has less than 256 colors, the rest
#  of the image is black.  If the color list has more than 256 colors
#  only the first 256 are processed.
#
#  The image file names have the basename of the color list files followed
#  by _p and the suffix .gif.
#
############################################################################
#
#  Requires:  Version 9 graphics
#
############################################################################
#
#  Links:  basename, wopen
#
############################################################################

link basename
link wopen

procedure main(args)
   local line, file, name, input, i, j, color

   WOpen("canvas=hidden", "size=16,16", "bg=black") |
      stop("*** cannot open window")

   every file := !args do {
      input := open(file) | {
         write(&errout, "*** cannot open ", file)
         next
         }
      name := basename(file, ".clr")
      EraseArea()
      every i := 0 to 15 do
         every j := 0 to 15 do {
         color := read(input) | break
         color ? {
            Fg(tab(upto('\t') | 0)) |
               write(&errout, "*** cannot set foreground")
            }
         DrawPoint(i, j)
         }
      WriteImage(name || "_p.gif")
      close(input)
      }

end