[PD] pd and custom tcl/tk gui

Andre Schmidt andre at osku.de
Mon Jul 31 21:23:07 CEST 2006


hi,

as pd uses tcl/tk as gui, wouldnt it be easy to allow users to add
custom tcl/tk script/gui ?

or

how can i send values from a "tot" scriptlet to pd ?

attached is a pd patch (tot-test1.pd) that opens a "tot" scriptlet
(rectresize.tot) in canvas, where you got a rectangle that you can
resize when click&drag on the rectangle edges... and i would like to
send the sizes (or what ever) to pd...

cheers
-andre

ps. some may know what i want to do:
http://osku.de/svg/foo/cirseq001b.mpeg
(was made with svg+ecmascript in firefox)
-------------- next part --------------
proc resize'rect'click {w x y} {
 global X Y RSZPOS ID
 set X [$w canvasx $x]
 set Y [$w canvasy $y]
 catch {unset RSZPOS}
 set ID [$w find withtag current]
 set coords [$w coords $ID]
 foreach {x0 y0 x1 y1} $coords break
 if {[between $x0 $y0 $X $Y $x0 $y1]} {
  set RSZPOS 0
 } elseif {[between $x0 $y1 $X $Y $x1 $y1]} {
  set RSZPOS 3
 } elseif {[between $x1 $y1 $X $Y $x1 $y0]} {
  set RSZPOS 2
 } elseif {[between $x1 $y0 $X $Y $x0 $y0]} {
  set RSZPOS 1
 }
}
proc resize'rect {w x y} {
 global X Y RSZPOS ID
 set x [$w canvasx $x]
 set y [$w canvasy $y]
 if [info exists RSZPOS] {
  set coords [$w coords $ID]
  set d [expr {$RSZPOS%2? $y: $x}]
  $w coords $ID [lset coords $RSZPOS $d]
 } else {
  $w move $ID [expr {$x-$X}] [expr {$y-$Y}]
 }
  set X $x; set Y $y
 }
proc between {x0 y0 x1 y1 x2 y2} {
 set t  10
 set xm [expr {($x0+$x2)/2.}]
 set ym [expr {($y0+$y2)/2.}]
 expr {abs($xm-$x1)<$t && abs($ym-$y1)<$t}
}
.^.c create rect 50 50 100 100 -fill red -tag rsz
.^.c bind rsz <1>         {resize'rect'click %W %x %y}
.^.c bind rsz <B1-Motion> {resize'rect %W %x %y}
-------------- next part --------------
#N canvas 521 45 316 117 10;
#X msg 215 25 push;
#N canvas 24 44 450 300 output 1;
#X restore 208 66 pd output;
#X obj 21 26 tot output rectresize.tot;
#X connect 0 0 2 0;
#X connect 2 3 0 0;


More information about the Pd-list mailing list