#N struct template3 float x float y float w float h float q;
#N canvas 264 23 641 553 12;
#X obj 328 255 pointer;
#X msg 344 222 next;
#X floatatom 328 345 4 0 0 0 - - - 0;
#N canvas 927 44 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 193 361 pd data3;
#N canvas 503 200 512 300 template3 0;
#X obj 48 98 filledpolygon q 0 1 0 0 w 0 w h 0 h;
#X text 44 53 five numeric ("float") fields;
#X text 48 118 drawing a rectangle \, interior color q \, 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 obj 46 33 struct template3 float x float y float w float h float
q;
#X text 53 241 This also allows you to click on the drawn number and
drag or type to change the color parameter.;
#X obj 49 207 drawnumber q 0 -5 0;
#X text 205 198 Draw the value of q as an Arabic numeral \, at (0 \,
-5) \, in black., f 32;
#X restore 90 361 pd template3;
#N canvas 395 94 513 527 stuff 0;
#X obj 182 285 pointer;
#X obj 175 456 append template3 x y w h q;
#X obj 168 48 loadbang;
#X obj 159 106 t b b b;
#X msg 182 237 traverse pd-data3;
#X msg 205 140 \; pd-data3 clear;
#X msg 138 154 0;
#X obj 85 180 f;
#X obj 124 181 + 1;
#X obj 87 156 until;
#X obj 105 210 sel 20;
#X obj 144 236 t b;
#X msg 159 78 bang;
#X obj 77 382 random 300;
#X obj 158 382 random 300;
#X obj 382 382 random 1000;
#X obj 239 382 random 80;
#X obj 311 382 random 80;
#X obj 159 22 inlet;
#X obj 158 408 + 30;
#X obj 182 314 trigger bang bang pointer;
#X connect 0 0 20 0;
#X connect 2 0 12 0;
#X connect 3 0 9 0;
#X connect 3 1 4 0;
#X connect 3 1 6 0;
#X connect 3 2 5 0;
#X connect 4 0 0 0;
#X connect 6 0 7 1;
#X connect 7 0 10 0;
#X connect 7 0 8 0;
#X connect 8 0 7 1;
#X connect 9 0 7 0;
#X connect 10 0 9 1;
#X connect 10 1 11 0;
#X connect 11 0 0 0;
#X connect 12 0 3 0;
#X connect 13 0 1 0;
#X connect 14 0 19 0;
#X connect 15 0 1 4;
#X connect 16 0 1 2;
#X connect 17 0 1 3;
#X connect 18 0 12 0;
#X connect 19 0 1 1;
#X connect 20 0 13 0;
#X connect 20 1 14 0;
#X connect 20 1 15 0;
#X connect 20 1 16 0;
#X connect 20 1 17 0;
#X connect 20 2 1 5;
#X restore 516 282 pd stuff;
#X msg 516 257 remake;
#X obj 328 311 get template3 x y w h q;
#X floatatom 446 345 4 0 0 0 - - - 0;
#X floatatom 407 345 4 0 0 0 - - - 0;
#X floatatom 367 345 4 0 0 0 - - - 0;
#X floatatom 486 345 4 0 0 0 - - - 0;
#X floatatom 56 244 4 0 0 0 - - - 0;
#X text 383 222 <= go to next;
#X obj 83 313 set template3 x y w h q, f 32;
#X obj 95 270 t b f;
#X floatatom 95 244 4 0 0 0 - - - 0;
#X obj 139 270 t b f;
#X floatatom 139 244 4 0 0 0 - - - 0;
#X obj 183 270 t b f;
#X floatatom 183 244 4 0 0 0 - - - 0;
#X obj 227 270 t b f;
#X floatatom 227 244 4 0 0 0 - - - 0;
#X text 62 222 x;
#X text 101 222 y;
#X text 145 222 w;
#X text 190 222 h;
#X text 233 222 q;
#X msg 328 191 traverse pd-data3 \, next;
#X text 108 189 get pointer to first scalar =>;
#X text 414 515 Updated for Pd version 0.52;
#X text 30 84 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. You can drag on the five number
boxes (after selecting an object with "traverse" and "next" messages)
to change its location \, shape \, and color., f 84;
#X text 30 15 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 (q). A new feature
is that the color is also drawn below the rectangles because we have
a [drawnumber] object in the template., f 84;
#X text 425 257 click to --> randomize, f 12;
#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 81 510 pd data-structures-colors;
#X text 24 400 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 connect 0 0 7 0;
#X connect 0 0 14 5;
#X connect 1 0 0 0;
#X connect 6 0 5 0;
#X connect 7 0 2 0;
#X connect 7 1 10 0;
#X connect 7 2 9 0;
#X connect 7 3 8 0;
#X connect 7 4 11 0;
#X connect 12 0 14 0;
#X connect 15 0 14 0;
#X connect 15 1 14 1;
#X connect 16 0 15 0;
#X connect 17 0 14 0;
#X connect 17 1 14 2;
#X connect 18 0 17 0;
#X connect 19 0 14 0;
#X connect 19 1 14 3;
#X connect 20 0 19 0;
#X connect 21 0 14 0;
#X connect 21 1 14 4;
#X connect 22 0 21 0;
#X connect 28 0 0 0;
