1// this config defines various heightmap brushes
2
3// a brush has two parts: the brushmap and the brushhandle
4
5// the brushmap is a 2D field that defines how the brush affects a heightmap
6
7// the brushhandle is a 2D vertex on the brushmap.
8// this handle is a reference point on the brushmap which represents
9// where the editing cursor is pointed at.
10
11// clearbrush                   : resets the brushmap
12// brushvert <x> <y> <value>    : set a point on the brushmap
13// brushx <x>                   : the x coordinate of the brushhandle
14// brushy <y>                   : the y coordinate of the brushhandle
15
16brushhandle = [
17  brushx $arg1
18  brushy $arg2
19]
20
21brushindex = -1
22brushmax = -1                // make sure to bump this up if you add more brushes
23
24selectbrush = [
25  brushindex = ( + $brushindex $arg1 )
26  if (< $brushindex 0) [ brushindex = $brushmax ]
27  if (> $brushindex $brushmax) [ brushindex = 0 ]
28  do [brush_@brushindex]
29  echo "heightmap brush set to:" $brushname
30]
31
32brushverts = [
33  loop y (listlen $arg1) [
34    bv = (at $arg1 $y)
35    loop x (listlen $bv) [
36      brushvert $x $y (at $bv $x)
37    ]
38  ]
39]
40
41newbrush = [
42  brushmax = (+ $brushmax 1)
43  do [
44    brush_@brushmax = [
45      brushname = [@@@arg1]
46      clearbrush
47      @@(if (> $numargs 1) [result [brushhandle @arg2 @arg3; brushverts [@@arg4]]])
48    ]
49  ]
50]
51
52newbrush "Circle 1-0" 0 0 [1]
53newbrush "Circle 2-1" 2 2 [
54    ""
55    "0 0 1 "
56    "0 1 2 1 "
57    "0 0 1 "
58]
59newbrush "Circle 4-2-1" 2 2 [
60  "0 0 1 "
61  "0 1 2 1 "
62  "1 2 4 2 1 "
63  "0 1 2 1 "
64  "0 0 1 "
65]
66newbrush "Square 3x3" 1 1 [
67  "1 1 1 "
68  "1 1 1 "
69  "1 1 1 "
70]
71newbrush "Square 5x5" 2 2 [
72  "1 1 1 1 1 "
73  "1 1 1 1 1 "
74  "1 1 1 1 1 "
75  "1 1 1 1 1 "
76  "1 1 1 1 1 "
77]
78newbrush "Square 7x7" 3 3 [
79  "1 1 1 1 1 1 1 "
80  "1 1 1 1 1 1 1 "
81  "1 1 1 1 1 1 1 "
82  "1 1 1 1 1 1 1 "
83  "1 1 1 1 1 1 1 "
84  "1 1 1 1 1 1 1 "
85  "1 1 1 1 1 1 1 "
86]
87
88newbrush "Smooth 3x3" 1 1 [
89  "0 0 0 "
90  "0 "
91  "0 "
92]
93newbrush "Smooth 5x5" 2 2 [
94  "0 0 0 0 0 "
95  "0 "
96  "0 "
97  "0 "
98  "0 "
99]
100newbrush "Smooth 7x7" 3 3 [
101  "0 0 0 0 0 0 0"
102  "0 "
103  "0 "
104  "0 "
105  "0 "
106  "0 "
107  "0 "
108]
109
110newbrush "Noise 25x25" 12 12 [
111  "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 "
112  ""
113  "0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 1 0 1 "
114  "0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 1 0 0 1 0 0 2 2 "
115  "0 0 0 0 1 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 1 "
116  "0 0 0 0 0 1 0 0 0 0 0 2 0 0 0 0 1 0 0 0 1 1 0 0 1 "
117  "0 0 1 0 0 0 1 0 1 1 0 0 0 0 1 0 0 1 0 0 0 0 2 "
118  "0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 2 "
119  "0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 1 1 "
120  "0 0 0 0 1 1 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 1 "
121  "0 1 0 2 0 1 1 1 1 0 0 1 0 0 0 0 1 "
122  "0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 "
123  "1 0 1 0 0 0 0 0 1 0 0 0 1 0 1 "
124  "0 0 0 0 0 0 0 1 1 0 1 1 0 0 1 0 0 1 0 0 0 0 1 0 0 1 "
125  "0 1 1 1 0 3 0 2 0 0 0 1 1 0 0 0 1 1 "
126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