#N struct template3 float x float y float w float h float c;
#N canvas 501 61 676 631 12;
#X obj 281 337 pointer;
#X msg 329 301 next;
#N canvas 961 36 381 425 data3 1;
#X scalar template3 18 85 43 18 741 \;;
#X scalar template3 111 169 75 25 72 \;;
#X scalar template3 111 92 4 15 163 \;;
#X scalar template3 59 61 13 34 563 \;;
#X scalar template3 148 86 37 20 566 \;;
#X scalar template3 173 281 76 48 763 \;;
#X scalar template3 250 187 18 36 543 \;;
#X scalar template3 124 270 78 21 107 \;;
#X scalar template3 264 243 1 33 178 \;;
#X scalar template3 26 88 56 60 132 \;;
#X scalar template3 2 262 66 2 808 \;;
#X scalar template3 270 106 74 51 881 \;;
#X scalar template3 214 286 8 43 180 \;;
#X scalar template3 57 205 51 58 939 \;;
#X scalar template3 216 162 36 43 505 \;;
#X scalar template3 166 146 68 9 614 \;;
#X scalar template3 144 251 56 28 886 \;;
#X scalar template3 228 62 62 1 758 \;;
#X scalar template3 168 229 28 23 654 \;;
#X scalar template3 223 308 73 50 727 \;;
#X coords 0 425 1 424 0 0 0;
#X restore 128 263 pd data3;
#N canvas 503 200 512 309 template3 0;
#X text 44 53 five numeric ("float") fields;
#X text 54 252 This also allows you to click on the drawn number and drag or type to change the color parameter.;
#X obj 55 210 drawnumber c 0 -5 0;
#X obj 46 33 struct template3 float x float y float w float h float c;
#X obj 48 98 filledpolygon c 0 1 0 0 w 0 w h 0 h;
#X text 48 118 drawing a rectangle \, interior color 'c' \, border black and one unit thick \, through the points (0 \, 0) \, (w \, 0) \, (w \, h) \, and (0 \, h). Note that the three points containing variables become hot spots for mouse dragging.;
#X text 205 198 Draw the value of 'c' as an Arabic numeral \, at (0 \, -5) coordinates \, in black., f 35;
#X restore 116 229 pd template3;
#X obj 84 367 t b f;
#X obj 131 367 t b f;
#X obj 178 367 t b f;
#X obj 225 367 t b f;
#X text 50 319 x;
#X text 95 319 y;
#X text 140 319 w;
#X text 186 319 h;
#X msg 281 260 traverse pd-data3 \, next;
#N canvas 187 23 851 535 data-structures-colors 0;
#X obj 660 183 vsl 15 128 0 255 0 0 empty empty empty 0 -9 0 10 #0800fc #fcfcfc #000000 0 1;
#X obj 639 183 vsl 15 128 0 255 0 0 empty empty empty 0 -9 0 10 #00fc00 #000000 #000000 0 1;
#X obj 619 183 vsl 15 128 0 255 0 0 empty empty empty 0 -9 0 10 #fc0000 #000000 #000000 0 1;
#X obj 660 319 t b f;
#X obj 650 361 t b f;
#X floatatom 596 461 5 0 0 0 - - - 16;
#X obj 596 397 expr 100*int(8*$f1/255) + 10*int(8*$f2/255) + int(8*$f3/255), f 25;
#X obj 212 197 t f f f;
#X obj 157 245 / 100;
#X obj 311 260 mod 10;
#X obj 235 243 / 10;
#X obj 235 267 mod 10;
#X floatatom 235 294 5 0 0 0 - - - 0;
#X floatatom 311 294 5 0 0 0 - - - 0;
#X floatatom 157 294 5 0 0 0 - - - 0;
#X obj 157 268 int;
#X obj 157 321 min 8;
#X floatatom 157 345 5 0 0 0 - - - 0;
#X obj 311 321 min 8;
#X floatatom 311 345 5 0 0 0 - - - 0;
#X obj 235 321 min 8;
#X floatatom 235 345 5 0 0 0 - - - 0;
#X floatatom 235 399 5 0 0 0 - - - 0;
#X floatatom 311 399 5 0 0 0 - - - 0;
#X floatatom 157 399 5 0 0 0 - - - 0;
#X obj 311 429 min 255;
#X obj 235 429 min 255;
#X obj 157 429 min 255;
#X text 34 16 Data Structures have a low color resolution. Basically \, "Red" values are represented by hundreds \, "Green" by tens and Blue by units. The resolution is about 8 values for each \, (counting from 0 to 7) \, where each step jumps '32' in values (so you go from 0 to 224). An extra step (8) is possible but it only jumps to '225'). A 647 value means '6' for "Red" \, '4' for "Green" and '7' for blue. Possible values range from 0 to 888 (where digits that are '9' are just clipped to 8). Below we convert from values Data Structures understand to RGB values., f 70;
#X obj 157 371 * 32;
#X obj 235 371 * 32;
#X obj 311 371 * 32;
#X floatatom 212 163 5 0 888 0 - - - 16;
#X floatatom 235 459 5 0 0 0 - - - 0;
#X floatatom 311 459 5 0 0 0 - - - 0;
#X floatatom 157 459 5 0 0 0 - - - 0;
#X obj 311 485 s blue;
#X obj 235 485 s green;
#X obj 157 485 s red;
#X obj 619 97 r red;
#X obj 639 127 r green;
#X obj 660 155 r blue;
#X text 549 15 Below we convert from RGB to a color value Data Structures understand. The sliders range from 0 to 255, f 36;
#X connect 0 0 3 0;
#X connect 1 0 4 0;
#X connect 2 0 6 0;
#X connect 3 0 6 0;
#X connect 3 1 6 2;
#X connect 4 0 6 0;
#X connect 4 1 6 1;
#X connect 6 0 5 0;
#X connect 7 0 8 0;
#X connect 7 1 10 0;
#X connect 7 2 9 0;
#X connect 8 0 15 0;
#X connect 9 0 13 0;
#X connect 10 0 11 0;
#X connect 11 0 12 0;
#X connect 12 0 20 0;
#X connect 13 0 18 0;
#X connect 14 0 16 0;
#X connect 15 0 14 0;
#X connect 16 0 17 0;
#X connect 17 0 29 0;
#X connect 18 0 19 0;
#X connect 19 0 31 0;
#X connect 20 0 21 0;
#X connect 21 0 30 0;
#X connect 22 0 26 0;
#X connect 23 0 25 0;
#X connect 24 0 27 0;
#X connect 25 0 34 0;
#X connect 26 0 33 0;
#X connect 27 0 35 0;
#X connect 29 0 24 0;
#X connect 30 0 22 0;
#X connect 31 0 23 0;
#X connect 32 0 7 0;
#X connect 33 0 37 0;
#X connect 34 0 36 0;
#X connect 35 0 38 0;
#X connect 39 0 2 0;
#X connect 40 0 1 0;
#X connect 41 0 0 0;
#X restore 132 594 pd data-structures-colors;
#X text 41 470 Note that you can set values with decimal points for the field names and they can be retrieved by [get]. Nonetheless \, the x/y coordinates and width/height parameters for the scalars depend on the 'units per pixel' parameters for 'x' and 'y' dimensions. In this example it is "1" for both \, so you'll only see the shape of the objects change if you increment in integers \, float values are just truncated. The color field is a special case and it only considers integer values. For more on how color values work \, see subpatch below:, f 84;
#X obj 281 205 bng 19 250 50 0 empty empty empty 0 -10 0 12 #dfdfdf #000000 #000000;
#N canvas 563 130 499 514 randomize 0;
#X obj 182 235 pointer;
#X msg 182 187 traverse pd-data3;
#X msg 258 90 \; pd-data3 clear;
#X msg 138 104 0;
#X obj 85 130 f;
#X obj 124 131 + 1;
#X obj 87 106 until;
#X obj 144 186 t b;
#X obj 60 332 random 300;
#X obj 141 332 random 300;
#X obj 374 332 random 1000;
#X obj 222 332 random 80;
#X obj 294 332 random 80;
#X obj 107 23 inlet;
#X obj 141 368 + 30;
#X obj 182 264 trigger bang bang pointer;
#X obj 105 160 sel 20;
#X obj 107 57 trigger bang bang bang;
#X obj 105 443 outlet;
#X obj 123 406 append template3 x y w h c, f 36;
#X connect 0 0 15 0;
#X connect 1 0 0 0;
#X connect 3 0 4 1;
#X connect 4 0 5 0;
#X connect 4 0 16 0;
#X connect 5 0 4 1;
#X connect 6 0 4 0;
#X connect 7 0 0 0;
#X connect 8 0 19 0;
#X connect 9 0 14 0;
#X connect 10 0 19 4;
#X connect 11 0 19 2;
#X connect 12 0 19 3;
#X connect 13 0 17 0;
#X connect 14 0 19 1;
#X connect 15 0 8 0;
#X connect 15 1 9 0;
#X connect 15 1 10 0;
#X connect 15 1 11 0;
#X connect 15 1 12 0;
#X connect 15 2 19 5;
#X connect 16 0 6 1;
#X connect 16 0 18 0;
#X connect 16 1 7 0;
#X connect 17 0 6 0;
#X connect 17 1 1 0;
#X connect 17 1 3 0;
#X connect 17 2 2 0;
#X restore 281 232 pd randomize;
#X floatatom 372 367 4 0 0 0 - - - 0;
#X floatatom 537 367 4 0 0 0 - - - 0;
#X floatatom 482 367 4 0 0 0 - - - 0;
#X floatatom 427 367 4 0 0 0 - - - 0;
#X floatatom 593 367 4 0 0 0 - - - 0;
#X msg 372 394 set \$1;
#X obj 372 420 s x;
#X msg 427 394 set \$1;
#X msg 482 394 set \$1;
#X msg 537 394 set \$1;
#X msg 593 394 set \$1;
#X obj 427 420 s y;
#X obj 482 420 s w;
#X obj 537 420 s h;
#X text 410 593 Updated for Pd version 0.53-1;
#X obj 281 367 t b p p;
#X obj 225 394 s h;
#X obj 178 394 s w;
#X obj 131 394 s y;
#X obj 84 394 s x;
#X floatatom 44 341 4 0 0 0 - x - 0;
#X floatatom 84 341 4 0 0 0 - y - 0;
#X floatatom 131 341 4 0 0 0 - w - 0;
#X floatatom 178 341 4 0 0 0 - h - 0;
#X floatatom 225 341 4 0 0 0 - c - 0;
#X text 454 259 <-- get pointer to first scalar, f 16;
#X text 30 18 The [set] object allows you to change field values. In this example \, the template specifies five fields describing the (x \, y) location \, width (w) \, height (h) \, and color (c). A new feature is that the color is also drawn below the rectangles because of a [drawnumber] object in the template., f 86;
#X text 233 319 c;
#X obj 372 336 get template3 x y w h c, f 32;
#X obj 69 420 set template3 x y w h c, f 34;
#X obj 271 394 s c;
#X obj 593 420 s c;
#X text 368 301 <-- get pointer of next scalar;
#X text 306 204 <-- click to re-initialize;
#X obj 281 178 loadbang;
#X text 30 83 Getting parameter values is as in the previous patch. However \, as you traverse the list with "next" messages the new pointers are also sent to the [set] object \, whose arguments define the template name and the name of the fields to set. Values from [get] set the number values of the 5 number boxes and you can drag them to change the parameters of scalars. Clicking the "next" message now loops back to the beginning of the list when reaching its end., f 86;
#X connect 0 0 32 0;
#X connect 0 1 12 0;
#X connect 1 0 0 0;
#X connect 4 0 36 0;
#X connect 4 1 46 1;
#X connect 5 0 35 0;
#X connect 5 1 46 2;
#X connect 6 0 34 0;
#X connect 6 1 46 3;
#X connect 7 0 33 0;
#X connect 7 1 46 4;
#X connect 12 0 0 0;
#X connect 15 0 16 0;
#X connect 16 0 12 0;
#X connect 17 0 22 0;
#X connect 18 0 26 0;
#X connect 19 0 25 0;
#X connect 20 0 24 0;
#X connect 21 0 27 0;
#X connect 22 0 23 0;
#X connect 24 0 28 0;
#X connect 25 0 29 0;
#X connect 26 0 30 0;
#X connect 27 0 48 0;
#X connect 32 0 47 0;
#X connect 32 1 46 5;
#X connect 32 2 45 0;
#X connect 37 0 46 0;
#X connect 38 0 4 0;
#X connect 39 0 5 0;
#X connect 40 0 6 0;
#X connect 41 0 7 0;
#X connect 45 0 17 0;
#X connect 45 1 20 0;
#X connect 45 2 19 0;
#X connect 45 3 18 0;
#X connect 45 4 21 0;
#X connect 51 0 15 0;
