############################################################################ # # 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