summaryrefslogtreecommitdiff
path: root/ipl/gpacks/weaving/drawscan.icn
blob: b3e6dfcf731dbacdafd3decd9f3088526fb5cd04 (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
############################################################################
#
#	File:     drawscan.icn
#
#	Subject:  Program to analyze scanned drawdowns
#
#	Author:   Ralph E. Griswold
#
#	Date:     May 14, 1999
#
############################################################################
#
#  This file is in the public domain.
#
############################################################################
#
#  AD HOC and experimental.  The parameters are setup for a 32x32 cell
#  draft.
#
############################################################################
#
#  Requires:  Version 9 graphics
#
############################################################################
#
#  Links:  numbers, wopen
#
############################################################################

link numbers
link wopen

$define Cells 32

procedure main(args)
   local x, y, pixel, popl, width, cellsize

   WOpen("canvas=hidden", "image=" || args[1]) | stop("*** cannot open image")

   width := WAttrib("width")

   cellsize := round(real(width) / Cells)

   writes(Cells, ",g2,")

   width := cellsize * Cells

   every y := 0 to width - cellsize / 2 by cellsize do {
      every x := 0 to width - cellsize / 2 by cellsize do {
         popl := table(0)
         every pixel := Pixel(x + 4, y + 4, cellsize - 8, cellsize - 8) do
               popl[PaletteKey("g2", pixel)] +:= 1
         popl := sort(popl, 4)
         pull(popl)
         writes(pull(popl))
         }
      }

   WriteImage("drawscan.gif")

end