[PD] Re: [PD-announce] GEM help!->looping..

Frank Barknecht fbar at footils.org
Sun Feb 19 11:40:26 CET 2006


Hallo,

(note: pd-announce is not meant for discussion, only for
announcements)

Kutsal K. Bilgin hat gesagt: // Kutsal K. Bilgin wrote:

> i have an array of size 360 and the values are either 1 or 0. each of these 
> values represent a degree in a 360 degree circle and if the value is 1 for 
> a particular index, i want to draw a little filled circle (o point) at that 
> degree on the main circle..
> 
> the problem is i don't know how to create loops as i would do when writing 
> in opengl, i need to create a loop to scan all the values in the array and 
> take the actions according to the values...

The trick here is to "multiply" a GemList sent from the gemhead
several times, using for example the [repeat] object or a counter
driven by [until]. To read from a table, a counter is better. 

To read out a table of length 100, you start a counter from 0-99 on
every gemhead-output. Then use this to generate proper messages for
the things you want to render. The rendering then has to be adapted as
well. [any] from IEMlib and Gem's seperator play a crucial role here.
You store the current gemstate in a [any]-object, then use the
messages you generated from about to repeatedly send this stored
gemstate to a [seperator] after which you do some transformations
according to your needs. 

I think, this is harder to explain in words for me that to just show
an example as attached. The [any]/[seperator] stuff is in [pd painter]

I used a [gemhead 45] inside [pd painter] to make this gemhead render
before the gemhead, that is used to drive the counter.

Ciao
-- 
 Frank Barknecht                 _ ______footils.org_ __goto10.org__
-------------- next part --------------
#N canvas 222 92 719 590 10;
#X obj 144 245 until;
#X msg 144 220 100;
#X obj 144 167 gemhead;
#X obj 144 284 f 0;
#X obj 174 284 + 1;
#X obj 206 285 mod 100;
#X obj 144 316 t f f;
#X obj 144 383 tabread x-s;
#X obj 176 402 tabread y-s;
#X obj 144 426 pack 0 0 0;
#X obj 141 47 cnv 15 100 60 empty empty empty 20 12 0 14 -195568 -66577
0;
#N canvas 0 0 450 300 gemwin 0;
#X obj 132 136 gemwin;
#X obj 67 89 outlet;
#X obj 67 10 inlet;
#X obj 67 41 route create;
#X msg 67 70 set destroy;
#X msg 155 70 set create;
#X msg 197 134 destroy;
#X msg 132 112 reset \, create \, 1;
#X connect 2 0 3 0;
#X connect 3 0 4 0;
#X connect 3 0 7 0;
#X connect 3 1 5 0;
#X connect 3 1 6 0;
#X connect 4 0 1 0;
#X connect 5 0 1 0;
#X connect 6 0 0 0;
#X connect 7 0 0 0;
#X restore 146 86 pd gemwin;
#X msg 146 67 destroy;
#X text 142 46 Create window:;
#X obj 527 286 s x-s;
#X obj 527 310 s y-s;
#X msg 527 258 const 0;
#N canvas 0 0 450 300 graph7 0;
#X array x-s 100 float 3;
#A 0 -3.77145 -3.71431 -3.77145 -3.71431 -3.65717 -3.65717 -3.60002
-3.54288 -3.42859 -3.42859 -3.37145 -3.31431 -3.25716 -3.20002 -3.14288
-3.08573 -3.02859 -2.97145 -2.85716 -2.80002 -2.68573 -2.57144 -2.5143
-2.40001 -2.34287 -2.22859 -2.17144 -2.1143 -2.1143 -2.05716 -2.00001
-1.94287 -1.82858 -1.77144 -1.7143 -1.60001 -1.48572 -1.42858 -1.31429
-1.25715 -1.14286 -1.02858 -0.971435 -0.914291 -0.857148 -0.742862
-0.628575 -0.514289 -0.457146 -0.342859 -0.285716 -0.228573 -0.114286
-0.0571432 0.0571432 0.17143 0.228573 0.285716 0.342859 0.400002 0.457146
0.514289 0.571432 0.685719 0.800005 0.88572 0.971435 1.05715 1.14286
1.22858 1.31429 1.42858 1.5143 1.60001 1.68572 1.77144 1.85715 1.94287
2.00001 2.05716 2.18573 2.3143 2.44287 2.57144 2.62859 2.68573 2.80002
2.9143 3.02859 3.13145 3.23431 3.33716 3.44002 3.54288 3.77145 3.8286
3.88574 4.00002 4.05717 4.11431;
#X coords 0 4 99 -4 200 140 1;
#X restore 303 167 graph;
#N canvas 0 0 450 300 graph8 0;
#X array y-s 100 float 3;
#A 0 -3.71437 -3.48579 -3.20007 -2.85721 -2.62863 -2.40005 -2.17148
-1.9429 -1.71432 -1.48575 -1.25717 -1.14288 -1.02859 -0.914307 -0.800018
-0.68573 -0.571442 -0.342865 -0.114288 0.114288 0.242863 0.371437 0.500011
0.628586 0.742874 0.871449 1.00002 1.1286 1.25717 1.4286 1.54289 1.60004
1.71432 1.77147 1.82861 1.82861 1.82861 1.82861 1.82861 1.82861 1.77147
1.77147 1.71432 1.65718 1.60004 1.4286 1.31432 1.20003 1.08574 1.02859
0.971451 0.800018 0.742874 0.742874 0.68573 0.68573 0.68573 0.742874
0.800018 0.971451 1.02859 1.14288 1.37146 1.54289 1.82861 2.11433 2.34291
2.51434 2.62863 2.80006 2.91435 3.02864 3.08578 3.20007 3.20007 3.25722
3.25722 3.25722 3.31436 3.31436 3.37151 3.37151 3.37151 3.42865 3.42865
3.42865 3.42865 3.42865 3.42865 3.42865 3.42865 3.54294 3.54294 3.54294
3.65723 3.71437 3.71437 3.77151 3.82866 -3.94295;
#X coords 0 4 99 -4 200 140 1;
#X restore 302 323 graph;
#N canvas 0 0 560 637 painter 1;
#X obj 297 127 inlet;
#X obj 297 411 translateXYZ;
#X obj 297 312 separator;
#X obj 297 225 any;
#X obj 326 380 unpack 0 0 0;
#X obj 297 438 square 0.025;
#X obj 297 148 t b a;
#X text 33 224 Repeatedly send current gemstate ...;
#X text 41 316 ... to seperate object transforms.;
#X obj 313 191 gemhead 45;
#X connect 0 0 6 0;
#X connect 1 0 5 0;
#X connect 2 0 1 0;
#X connect 3 0 2 0;
#X connect 4 0 1 1;
#X connect 4 1 1 2;
#X connect 4 2 1 3;
#X connect 6 0 3 0;
#X connect 6 1 4 0;
#X connect 9 0 3 1;
#X restore 144 448 pd painter;
#X obj 144 195 t b b;
#X msg 189 219 0;
#X connect 0 0 3 0;
#X connect 1 0 0 0;
#X connect 2 0 20 0;
#X connect 3 0 4 0;
#X connect 3 0 6 0;
#X connect 4 0 5 0;
#X connect 5 0 3 1;
#X connect 6 0 7 0;
#X connect 6 1 8 0;
#X connect 7 0 9 0;
#X connect 8 0 9 1;
#X connect 9 0 19 0;
#X connect 11 0 12 0;
#X connect 12 0 11 0;
#X connect 16 0 15 0;
#X connect 16 0 14 0;
#X connect 20 0 1 0;
#X connect 20 1 21 0;
#X connect 21 0 3 1;


More information about the Pd-list mailing list