summaryrefslogtreecommitdiff
path: root/ipl/gpacks/weaving/wallpapr.icn
blob: c1c30a083ab6f2d97d71f2149666e8e334794670 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
############################################################################
#
#	File:     wallpapr.icn
#
#	Subject:  Program to generate mutant shadow weave wallpaper
#
#	Author:   Ralph E. Griswold
#
#	Date:     June 19, 1999
#
############################################################################
#
#  This file is in the public domain.
#
############################################################################
#
#  This program is based on the Painter weave "Shadow Op Art".
#
############################################################################
#
#  Links:  random, tieutils, weavegif, weavutil
#
############################################################################

link random
link tieutils
link weavegif
link weavutil

global anchors
global palpat
global palindromes

procedure main(args)
   local tieup, palette, mutant, win1, win2, colorways, i

   randomize()

   # In this instantiation, the tieup and palindrome sequence
   # basis are fixed.  Anchors are shuffled (permuted randomly),
   # but the palindromes attached to the anchors.  That is,
   # the anchors and attached palindromes are permuted together.

   anchors := "1234567"
   palpat := "82143657"
   tieup := "8,#8040201008040201"	# NOTE:  this is direct tie-up
   palette := "g2"

   palindromes := list(*palpat)

   every i := 1 to *palpat do
      palindromes[i] := "[" || palpat[1:i] || "!" || palpat[i] || "]"

   mutant := draft()
   mutant.name := "Shadow Weave Variation"
   mutant.shafts := 8
   mutant.treadles := 8
   mutant.colors := PaletteChars(palette)
   mutant.palette := palette
   mutant.tieup := tieup

   every 1 to 10 do {
      anchors := shuffle(anchors)
      mutant.threading := mutant.treadling := "[" || thread(1) || "|]"
      mutant.warp_colors := "12"
      mutant.weft_colors := "21"
      win2 := weavegif(expandpfd(mutant), ["canvas=hidden"])
      WriteImage(win2, "bandw.gif")
      WDelay(win2, 10000)
      WClose(win2)
      }

   # Because of a memory leak (possibly in X), it is necessary to
   # terminate this program at intervals and start up a new version.

   system("wallpapr &")

   exit()

end

#  Compute sequence as pattern-form.

procedure thread(i)
   local result

   if i = *palpat then return ""

   result := "-[" || anchors[i] || "-[" || palindromes[i] ||
      thread(i + 1) || "]]"

   if i = 1 then result := result[2:0]

   return result

end