[PD] pd-datastruct newbie :-)

Frank Barknecht fbar at footils.org
Wed Mar 30 23:06:09 CEST 2005


Hallo,
federico hat gesagt: // federico wrote:

> if you look at the attached patch, i realized a template for array 
> container (arr) and one for array point (node).
> 
> now i have some questions:
> 1) although the template for node has only x/y vars, (in the data 
> window) i get the resize handle too.... but i haven't supplied a 'w' 
> field in 'node'. why? my intention was: to connect these x/y points by a 
> fixed width line.

You have some error in your use of [filledpolygon]: The argument count
is wrong. I replaced them both with [drawpolygon] and then the width
error went away. It's strange, that Pd reacts like this to a wrong
usage of [filledpolygon], though.

> 2) after placing the array, i use [setsize] to set num. of elements in 
> it. but the container doesn't grows horizontally, so it is painful have 
> 10 points, all in the same x/y coordinate.

That's because you are using array elements that have a field "float
x", so [plot] will take the x-spacing from the "node.x" value. This
equals 0 after creation so all elements will be at x=0 (or rather at
the point, where you start to [plot] which is not 0 in your example
but 100).  Attached patch shows one possible way to set the array
element's x-values after creation.

> 3) it is possible to set a constraint on a specific field? (i.e.: i do 
> not want the x value of a point to be negative.)

Not that I know. One neat trick could be to use the [mousefilter]
external to catch mouse-up events and then check all values and reset
them if needed. 

Ciao
-- 
 Frank Barknecht                               _ ______footils.org__
             
          _ __latest track: "scans" _ http://footils.org/cms/show/41
-------------- next part --------------
#N struct arr float x float y array pts node;
#N struct node float x float y;
#N canvas 594 370 619 510 10;
#N canvas 47 275 450 300 paint 1;
#X scalar arr 0 0 \; -56 66 \; -22 30 \; 34 33 \; 65 65 \; 63 103 \;
41 159 \; -16 163 \; -60 73 \; -16 81 \; 42 79 \; \;;
#X restore 16 64 pd paint;
#N canvas 662 84 450 300 node 0;
#X obj 58 76 struct node float x float y;
#X obj 66 159 drawpolygon 900 10 0 0 10 0;
#X restore 16 43 pd node;
#X obj 137 35 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X msg 337 99 \; pd-paint clear;
#X msg 317 134 traverse pd-paint \, bang;
#X obj 317 157 pointer;
#N canvas 511 554 450 300 arr 0;
#X obj 101 87 struct arr float x float y array pts node;
#X obj 101 127 plot pts 700 3 100 0;
#X obj 102 184 drawpolygon 0 5 0 0 90 0 0 0 300 0;
#X restore 16 22 pd arr;
#X obj 282 196 append arr x y;
#X obj 167 293 setsize arr pts;
#X obj 260 157 t b f f;
#X msg 403 443 traverse pd-paint \, next;
#X obj 403 466 pointer;
#X obj 137 55 t b b b b b b b b b b b b;
#X obj 167 258 10;
#X text 158 30 < clear \, create array \, resize array;
#X obj 182 407 element arr pts;
#X text 315 367 <== and again!;
#X text 289 236 <== This pointer can be used immediatly!;
#X obj 95 312 until;
#X obj 129 258 10;
#X obj 95 340 f 0;
#X obj 123 340 + 1;
#X obj 109 366 t f f;
#X obj 117 449 set node x;
#X msg 142 315 0;
#X obj 117 405 * 20;
#X obj 260 135 0;
#X connect 2 0 12 0;
#X connect 4 0 5 0;
#X connect 5 0 7 2;
#X connect 7 0 8 1;
#X connect 7 0 15 1;
#X connect 9 1 7 0;
#X connect 9 2 7 1;
#X connect 10 0 11 0;
#X connect 12 1 19 0;
#X connect 12 2 13 0;
#X connect 12 5 24 0;
#X connect 12 8 26 0;
#X connect 12 10 4 0;
#X connect 12 11 3 0;
#X connect 13 0 8 0;
#X connect 15 0 23 1;
#X connect 18 0 20 0;
#X connect 19 0 18 0;
#X connect 20 0 21 0;
#X connect 20 0 22 0;
#X connect 21 0 20 1;
#X connect 22 0 25 0;
#X connect 22 1 15 0;
#X connect 24 0 20 1;
#X connect 25 0 23 0;
#X connect 26 0 9 0;


More information about the Pd-list mailing list