[PD] Beginner's Question: templates

marius schebella marius.schebella at gmail.com
Tue Mar 18 18:27:59 CET 2008


hi andrew,
welcome to the pd-list
you want to use data structures to draw shapes, which is maybe a bit of 
overkill for what you want to do, but I am not sure what exactly you 
want to do, so I will just explain...
the drawpolygon itself does not accept input like you patched it 
together. it uses special data that has to be entered in a special way.
have a look at the example patches for data structures, esp. 3.setting.
so what you need to do is:
1. create data, 2. change data

1. to create data use "append".
set a pointer to the window where you want to create the data
[traverse pd-dw1, bang(
  |
[pointer]
          \
           \ (connect to right inlet)
            \
[append temp1 col]

dw1 is the patchwindow where you want to draw. this can be a subwindow 
or the patch itself [traverse pd-mypatch.pd(. temp1 is the name of your 
struct and col is one variable of the struct (see below). and then 
create one dataset by sending one single message to the left inlet of append

[900(
|
[append temp1 col]

if you have a struct and a drawpolygon, this will draw the polygon.
[struct temp1 float col]
[drawpolygon col 1 20 20 60 20 40 40 20 20] which would draw a polygon 
with points at 20 20, 60 20 and 40 40, line thickness 1 and color 900, 
which is red.

once the data is created it will be stored with your patch, and you 
don't have to repeat that again., you just change the color via set.
but you must set a pointer message again and also a "next" message!

[traverse pd-dw1, next(
  |
[pointer]
          \
           \ (connect to right inlet)
            \
[set temp1 col]

finally you can connect a number box to the left inlet and change the 
color of your polygon.
[channel]
  |
[* 171]
  |
[mod 1000]
  |
[set temp1 col]

that's it. I attach a patch called ds1.pd.
marius.



Andrew Dabrowski wrote:
> I posted this to the puredata.hurleur.com forum, but didn't get any
> responses.
> 
> I'm brand new to pd.
> 
> I'd like to make a template that represents the midi channel by color.
> So I'd like to change the channel number to one between 0-999, say
> 
>      [channel]
>       |
>      [* 171]
>       |
>      [mod 1000]
>       |
>      [drawpolygon $1 .....]
> 
> The problem is, how do I call the channel field of the struct from
> inside the template?  I know I can call channel directly inside
> [drawpolygon ....], but then I can't do any arithmetic on it before
> using it as a color.
> 
> I know I could define a new field in the struct, say clr, set up an
> abstraction to define it correctly from channel, then call clr inside
> [drawpolygon ....], but that seems ugly.
> 
> 
> _______________________________________________
> PD-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
> 

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ds1.pd
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20080318/2cf06b6c/attachment.asc>


More information about the Pd-list mailing list