#N struct template6 float x float y array bazoo template6-element1 array boom template6-element2 array blargh float;
#N struct template6-element1 float y;
#N struct template6-element2 float x float y float w float i;
#N struct float float y;
#N canvas 83 14 717 660 12;
#X obj 284 488 pointer;
#X floatatom 56 465 4 0 0 0 - - - 0;
#X obj 435 381 pointer;
#N canvas 823 19 386 321 data6 1;
#X scalar template6 30 50 \; 0 \; 0 \; 0 \; 0 \; 50 \; 0 \; 0 \; 0 \; 0 \; 0 \; 0 \; -9 \; 0 \; 0 \; 0 \; 3 \; 0 \; 0 \; 0 \; 30 \; 0 \; 0 \; 0 \; -43 \; 0 \; \; 0 80 10 0 \; 10 50 2 1 \; 200 75 15 2 \; 225 25 1 3 \; 40 100 5 4 \; \; 10 \; 11 \; 11 \; 11 \; 11 \; 11 \; 11 \; 11 \; 11 \; 11 \; 11 \; 11 \; 10 \; 10 \; 10 \; 10 \; 10 \; 10 \; 9 \; 9 \; 8 \; 8 \; 8 \; 7 \; 6.66667 \; 6.33333 \; 6 \; 6 \; 6 \; 6 \; 6 \; 6 \; 6 \; 6 \; 6 \; 6 \; 6 \; 5 \; 5 \; 5 \; 5 \; 4.5 \; 4 \; 4 \; 4 \; 4 \; 4 \; 4 \; 4 \; 4 \; 4 \; 4 \; 4 \; 4 \; 4 \; 4 \; 4 \; 4 \; 4 \; 5 \; 6 \; 7 \; 8 \; 8.5 \; 9 \; 10 \; 11 \; 12 \; 13 \; 14 \; 16 \; 16.3333 \; 16.6667 \; 17 \; 19 \; 22 \; 22 \; 24 \; 26 \; 27 \; 28 \; 28 \; 30 \; 32 \; 32 \; 33 \; 33.5 \; 34 \; 34 \; 34.5 \; 35 \; 36 \; 36 \; 37 \; 37 \; 37 \; 36 \; 35 \; 34 \; 32 \; 30 \; 29 \; 28 \; 25 \; 24 \; 23 \; 22 \; 18 \; 16 \; 14 \; 13 \; 9 \; 7 \; 6.33333 \; 5.66667 \; 2 \; 1 \; 0 \; -2 \; -5 \; -8 \; -8.5 \; -9 \; -13 \; -14 \; -17 \; -19 \; -20 \; -21 \; -23 \; -25 \; -26 \; -26 \; -26 \; -27 \; -27 \; -27 \; -26 \; -25 \; -24.5 \; -24 \; -22 \; -21.5 \; -21 \; -20.5 \; -20 \; -19 \; -18 \; -17 \; -16 \; -14.3333 \; -12.6667 \; -11 \; -10.3333 \; -9.66667 \; -9 \; -7.5 \; -6 \; -5 \; -4 \; -3 \; -2 \; -0.5 \; 1 \; 3 \; 5 \; 8 \; 8.33333 \; 8.66667 \; 12 \; 13 \; 14 \; 14.6667 \; 15.3333 \; 16 \; 17 \; 18 \; 19.5 \; 21 \; 22 \; 23 \; 24 \; 25 \; 28 \; 31 \; 32 \; 34 \; 35 \; 36 \; 37 \; 37 \; 39 \; 39 \; 39 \; 40 \; 41 \; 42 \; 42 \; 43 \; 44 \; 44 \; 45 \; 46 \; 47 \; 47 \; 48 \; 49 \; 49 \; 50 \; 51 \; 51 \; 51 \; 52 \; 52 \; 53 \; 54 \; 54 \; 54 \; 55 \; 55 \; 55 \; 55 \; 55 \; 55 \; 55 \; 55 \; 55 \; 55 \; 55 \; 55 \; 55 \; 55 \; 54 \; 54 \; 54 \; 54 \; 54 \; 54 \; 53 \; 52 \; 52 \; 51 \; 51 \; 50 \; 49 \; 49 \; 49 \; 48 \; 47 \; 46 \; 45 \; 44 \; 44 \; 44 \; 43 \; 40 \; \;;
#X coords 0 321 1 320 0 0 0;
#X restore 506 495 pd data6;
#N canvas 131 53 529 558 template6 0;
#X obj 24 213 plot bazoo 700 3 30 10 10;
#X text 28 122 This [struct] now also declares arrays named "bazoo" and "boom" whose elements are described by spearate template named \, named respectively "template6-element1" and "template6-element2". Array declarations need this extra element's template name which is declared on a separate subpatch., f 65;
#X text 212 214 draw instruction for the 'bazoo' array;
#X text 31 247 The first argument of [plot] is the array name (bazoo) \, other arguments are: color (700) \, line width (3) \, position coordinate (30 \, 40) and horizontal spacing for the elements (5)., f 64;
#X text 220 324 draw instruction for the 'boom' array;
#X obj 126 30 struct template6 float x float y array bazoo template6-element1 array boom template6-element2 array blargh float, f 32;
#X text 226 416 draw instruction for the 'blargh' array;
#X text 41 358 Since the 'boom' array defines x and w fields \, the arguments for line width and horizontal spacing are ignored in [plot].;
#X text 58 451 This one has a built in float template so we don't need a subpatch to define its element. This is a simple template also used for regular arrays in Pd. Here we plot it with a purple line with a thickness of 2 pixels. It is initialized with a size of 1 \, but you can change it with [setsize].;
#X obj 53 323 plot boom 90 1 30 50 1;
#X obj 43 416 plot blargh 909 2 30 200;
#X restore 506 518 pd template6;
#X msg 435 353 traverse pd-data6 \, next;
#X floatatom 94 400 4 0 256 0 - - - 0;
#X floatatom 284 403 4 0 4 0 - - - 0;
#X floatatom 284 542 7 0 0 1 y-value - - 0;
#X text 53 583 When you press the control (or "command" in mac) before passing the mouse over a point \, the cursor becomes an "X" so you can click and remove that point or it becomes "+" so you can click and add a new point to the array., f 56;
#X text 497 623 Updated for version Pd 0.52;
#X text 566 395 see also:;
#X obj 644 395 array;
#N canvas 196 208 538 281 template6-element1 0;
#X text 34 124 We don't really need any drawing instructions for the elements in the array. Note that the top-level template has drawing instructions for the array with the [plot] object. Nonetheless \, we have a small polygon drawn here for each element in the array., f 69;
#X obj 100 21 struct template6-element1 float y;
#X text 27 54 This says that array elements will have a single floating-point number named "y". The variable name "y" is automatically assumed to control the vertical position and it's needed to plot 'y-values'. It also allows you to click and drag to change the y-value of each element., f 70;
#X obj 119 211 drawpolygon 0 2 -2 -2 2 -2 2 2 -2 2 -2 -2;
#X restore 506 541 pd template6-element1;
#N canvas 230 117 497 280 template6-element2 0;
#X obj 78 187 filledpolygon 900 0 2 -2 -2 2 -2 2 2 -2 2;
#X text 81 158 draw a filled polygon on each element.;
#X obj 66 21 struct template6-element2 float x float y float w float i;
#X obj 81 226 drawnumber i 10 5;
#X text 213 226 draw the value of 'i';
#X text 54 55 This says that array elements have special fields x \, y and w \, which set coordinates (x \, y) and line width (w). We can also include other data types and here we add an extra float data type named "i" (used for the array's index). Alternatively \, you can also add symbol fields \, text fields and even nested arrays indefinitely., f 55;
#X restore 506 563 pd template6-element2;
#X text 30 242 The [elemment] object takes an index number and outputs a pointer to the corresponding array element. The [setsize] object sets the array size and [getsize] gets it \, but note you can also use [array] for this and other operations on arrays instead., f 93;
#X text 30 193 Like explained with other scalars \, the x/y/w values depend on the 'Units per pixel' parameter for the x/y dimensions (1 for both in this case). This means that the display will only increment in integer vaues \, even though you can set values with decimal points., f 93;
#X obj 94 437 setsize template6 blargh;
#X floatatom 459 424 5 0 0 0 - - - 0;
#X obj 435 319 bng 25 250 50 0 empty empty <--\ click\ here\ first 32 13 0 14 #dfdfdf #000000 #000000;
#X text 30 10 Scalars may also contain arrays \, whose elements are also scalars with their own template and can include any data type (float \, symbols \, text and even sub-arrays recursively.) In this case \, "template6" contains the definition of the top-level scalar and we have two templates: "template6-element1" for the elements of the 'bazoo' array and "template6-element2" for the elements of the 'boom' array. A third array ('blargh') has a builtin float template. See the template subpatches for more information., f 93;
#X text 30 102 The elements of the array usually have at least a float field 'y' for the vertical values of the array \, but you can also have an 'x' field to set the horizontal value and there's also a special 'w' field that controls the line width. When these three fields are given (as in the green array in this example) you can click on an array point and move it bidimensionally \, and when the cursor becomes a double vertical arrow you can click and drag vertically to change the width. This template also has an 'i' field for the array index \, which is plotted., f 93;
#X text 71 520 [set] and [get] work as before \, but on array elements..., f 20;
#X text 601 518 <-- top-level;
#N canvas 260 134 601 508 initialize 0;
#X obj 112 170 pointer;
#X text 64 43 click here to re-initialize;
#X msg 270 124 \; pd-data6 clear;
#X msg 112 125 traverse pd-data6 \, bang, f 18;
#X obj 497 324 element template6 bazoo, f 10;
#X obj 38 85 trigger bang bang bang, f 31;
#X obj 336 179 trigger bang bang pointer, f 33;
#X msg 450 223 25;
#X msg 336 207 50 4 \, 3 15 \, -9 11 \, 30 19 \, -43 23, f 6;
#X text 494 301 index;
#X obj 450 248 array size -s template6 bazoo, f 15;
#X obj 336 338 set template6-element1 y, f 20;
#X obj 38 244 trigger pointer pointer, f 24;
#X obj 336 296 unpack;
#X obj 37 277 trigger bang bang pointer, f 27;
#X obj 244 415 element template6 boom, f 17;
#X msg 130 313 5;
#X obj 130 343 setsize template6 boom, f 14;
#X obj 37 394 t l b;
#X obj 268 391 + 1;
#X msg 252 362 0;
#X msg 38 145 30 50;
#X obj 38 208 append template6 x y;
#X obj 38 44 bng 19 250 50 0 empty empty empty 17 7 0 10 #dfdfdf #000000 #000000;
#X obj 38 14 loadbang;
#X obj 37 466 set template6-element2 x y w i;
#X obj 192 430 t f f;
#X obj 220 387 float;
#X msg 37 308 0 80 10 \, 10 50 2 \, 200 75 15 \, 225 25 1 \, 40 100 5, f 10;
#X connect 0 0 22 2;
#X connect 3 0 0 0;
#X connect 4 0 11 1;
#X connect 5 0 21 0;
#X connect 5 1 3 0;
#X connect 5 2 20 0;
#X connect 5 2 2 0;
#X connect 6 0 8 0;
#X connect 6 1 7 0;
#X connect 6 2 4 1;
#X connect 6 2 10 1;
#X connect 7 0 10 0;
#X connect 8 0 13 0;
#X connect 12 0 14 0;
#X connect 12 1 6 0;
#X connect 13 0 11 0;
#X connect 13 1 4 0;
#X connect 14 0 28 0;
#X connect 14 1 16 0;
#X connect 14 2 15 1;
#X connect 14 2 17 1;
#X connect 15 0 25 4;
#X connect 16 0 17 0;
#X connect 18 0 25 0;
#X connect 18 1 27 0;
#X connect 19 0 27 1;
#X connect 20 0 27 1;
#X connect 21 0 22 0;
#X connect 22 0 12 0;
#X connect 23 0 5 0;
#X connect 24 0 23 0;
#X connect 26 0 25 3;
#X connect 26 1 15 0;
#X connect 27 0 19 0;
#X connect 27 0 26 0;
#X connect 28 0 18 0;
#X restore 506 586 pd initialize;
#X obj 459 456 array set -s template6 bazoo;
#X obj 284 437 element template6 boom;
#X obj 284 516 get template6-element2 y;
#X obj 56 492 set template6-element2 y;
#X obj 284 301 vradio 19 1 0 5 empty empty empty 0 -10 0 12 #dfdfdf #000000 #000000 0;
#X text 313 309 <---- select element from index, f 8;
#X text 82 326 set 'blargh' size (purple array initialized with a size of 1), f 17;
#X connect 0 0 27 0;
#X connect 1 0 28 0;
#X connect 2 0 17 1;
#X connect 2 0 25 2;
#X connect 2 0 26 1;
#X connect 5 0 2 0;
#X connect 6 0 17 0;
#X connect 7 0 26 0;
#X connect 18 0 25 0;
#X connect 19 0 5 0;
#X connect 26 0 0 0;
#X connect 26 0 28 1;
#X connect 27 0 8 0;
#X connect 29 0 7 0;
