1
2
3\environment luametafunstyle
4
5\startcomponent luametafunpoisson
6
7\startchapter[title={Poisson}]
8
9
10When, after a post on the \CONTEXT\ mailing list, Aditya pointed me to an article
11on mazes I ended up at poisson distributions which to me looks nicer than what I
12normally do, fill a grid and then randomize the resulting positions. With some
13hooks this can be used for interesting patterns too. The algorithm is based on
14the discussion at:
15
16\starttyping
17http:devmag.org.za20090503poissondisksampling
18\stoptyping
19
20Other websites mention some variants on that but I saw no reason to look into
21those in detail. I can imagine more random related variants in this domain so
22consider this an appetizer. The user is rather simple because some macro is
23assumed to deal with the rendering of the distributed points. We just show some
24examples (because the interface might evolve).
25
26\startbuffer
27\startMPcode
28 draw lmt_poisson [
29 width = 40,
30 height = 40,
31 distance = 1,
32 count = 20,
33 macro = "draw"
34 ] xsized 4cm ;
35\stopMPcode
36\stopbuffer
37
38\typebuffer[option=TEX]
39
40\startlinecorrection
41 \getbuffer
42\stoplinecorrection
43
44\startbuffer
45\startMPcode
46 vardef tst (expr x, y, i, n) =
47 fill fullcircle scaled (10+10(in)) shifted (10x,10y)
48 withcolor "darkblue" withtransparency (1,.5) ;
49 enddef ;
50
51 draw lmt_poisson [
52 width = 50,
53 height = 50,
54 distance = 1,
55 count = 20,
56 macro = "tst",
57 arguments = 4
58 ] xsized 6cm ;
59\stopMPcode
60\stopbuffer
61
62\typebuffer[option=TEX]
63
64\startlinecorrection
65 \getbuffer
66\stoplinecorrection
67
68\startbuffer
69\startMPcode
70 vardef tst (expr x, y, i, n) =
71 fill fulldiamond scaled (5+5(in)) randomized 2 shifted (10x,10y)
72 withcolor "darkgreen" ;
73 enddef ;
74
75 draw lmt_poisson [
76 width = 50,
77 height = 50,
78 distance = 1,
79 count = 20,
80 macro = "tst",
81 initialx = 10,
82 initialy = 10,
83 arguments = 4
84 ] xsized 6cm ;
85\stopMPcode
86\stopbuffer
87
88\typebuffer[option=TEX]
89
90\startlinecorrection
91 \getbuffer
92\stoplinecorrection
93
94\startbuffer
95\startMPcode{doublefun}
96 vardef tst (expr x, y, i, n) =
97 fill fulldiamond randomized (.2in) shifted (x,y);
98 enddef ;
99
100 draw lmt_poisson [
101 width = 150,
102 height = 150,
103 distance = 1,
104 count = 20,
105 macro = "tst",
106 arguments = 4
107 ] xsized 6cm withcolor "darkmagenta" ;
108\stopMPcode
109\stopbuffer
110
111\typebuffer[option=TEX]
112
113\startlinecorrection
114 \getbuffer
115\stoplinecorrection
116
117\startbuffer
118\startMPcode
119 vardef tst (expr x, y, i, n) =
120 draw externalfigure "cow.pdf" ysized (10+5in) shifted (10x,10y);
121 enddef ;
122 draw lmt_poisson [
123 width = 20,
124 height = 20,
125 distance = 1,
126 count = 20,
127 macro = "tst"
128 arguments = 4,
129 ] xsized 6cm ;
130\stopMPcode
131\stopbuffer
132
133\typebuffer[option=TEX]
134
135\startlinecorrection
136 \getbuffer
137\stoplinecorrection
138
139The supported parameters are:
140
141\starttabulate[TTTp]
142\FL
143\BC name \BC type \BC default \BC comment \NC \NR
144\ML
145\NC width \NC numeric \NC 50 \NC \NC \NR
146\NC height \NC numeric \NC 50 \NC \NC \NR
147\NC distance \NC numeric \NC 1 \NC \NC \NR
148\NC count \NC numeric \NC 20 \NC \NC \NR
149\NC macro \NC string \NC "draw" \NC \NC \NR
150\NC initialx \NC numeric \NC 10 \NC \NC \NR
151\NC initialy \NC numeric \NC 10 \NC \NC \NR
152\NC arguments \NC numeric \NC 4 \NC \NC \NR
153\LL
154\stoptabulate
155
156\stopchapter
157
158\stopcomponent
159
160 |