[PD-cvs] extensions/gui/ix mat-demo.pd,NONE,1.1 mat.wid,NONE,1.1
carmen rocco
ix9 at users.sourceforge.net
Mon May 16 14:23:52 CEST 2005
Update of /cvsroot/pure-data/extensions/gui/ix
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5747
Added Files:
mat-demo.pd mat.wid
Log Message:
mat (not done)
----------------------------------------------------------------------
--- NEW FILE: mat.wid ---
package require tkpath
namespace eval ::ix {
proc random_int {} {return [expr "int(floor(rand()*16))"]}
proc random_clr {} {
return [format "\#%1X%1X%1X%1X%1X%1X" [random_int] [random_int] [random_int] [random_int] [random_int] [random_int]]
}
variable _
proc mat_click {what p t x y} {
variable _
switch $what {
motion {
foreach xy {x y} {
set mv [mat_tr $p $t $xy d [expr $$xy - $_($t:c$xy)]]
foreach ab {a b} {
set _($t:${xy}$ab) [expr $_($t:${xy}$ab) - $mv]
}
mat_gridlines $p $t
}
}
}
foreach xy {x y} {set _($t:c$xy) [set $xy]}
}
proc mat_tr {p t d inv v} {
variable _
array set dm {x width y height}
switch $inv {
t {return [expr ($v - $_($t:${d}a)) / ($_($t:${d}b) - $_($t:${d}a) + 0.0) * [winfo $dm($d) $p.m]]}
i {return [expr ($_($t:${d}b) - $_($t:${d}a)) * $v /([winfo $dm($d) $p.m] + 0.0) + $_($t:${d}a)]}
d {return [expr ($_($t:${d}b) - $_($t:${d}a)) * $v /([winfo $dm($d) $p.m] + 0.0)]}
}
}
proc mat_new {path target w h bg ln Xa Xb Ya Yb qXv qYv} {
variable _
set _($target:ln) $ln
set _($target:qxv) $qXv
set _($target:qyv) $qYv
set _($target:ya) $Ya
set _($target:xa) $Xa
set _($target:yb) $Yb
set _($target:xb) $Xb
if {[winfo exists $path.m] != 1} {
canvas $path.m -bg $bg -width $w -height $h
pack $path.m -side left
bind $path.m <1> "::ix::mat_click first $path $target %x %y"
bind $path.m <B1-Motion> "::ix::mat_click motion $path $target %x %y"
bind $path.m <ButtonRelease-1> "::ix::mat_click release $path $target %x %y"
mat_gridlines $path $target
set bd [expr {[$path cget -bd] * 2}]
$path configure -bg gray -width [expr [winfo width $path.m] + $bd] \
-height [expr [winfo height $path.m] + $bd]}}
proc mat_gridlines {path target} {
variable _
# puts gridlines
set w $path.m
$w delete gridlines
set gh [winfo height $w]
set gw [winfo width $w]
foreach item [$path.m find withtag gridline] {$path.m delete $item}
foreach xy {x y} {
array set ta {x n y w}
array set tj {x center y left}
array set igx {y width x height}
for {set x [expr int($_($target:${xy}a) / ($_($target:q${xy}v) + 0.0) + 1)*($_($target:q${xy}v) + 0.0)]} {$x <= $_($target:${xy}b)} {set x [expr $x + $_($target:q${xy}v)]} {
set og [mat_tr $path $target $xy t $x]
set invgeo [winfo $igx($xy) $path.m]
switch $xy {y {set coords [concat M 0 $og L $invgeo $og]}
x {set coords [concat M $og 0 L $og $invgeo]}}
$w create path $coords -stroke $_($target:ln) -strokedasharray 2 -tags gridline -strokewidth 1
$w create text [lrange $coords 1 2] -font {{Bitstream Vera Sans} 8} \
-fill green -anchor $ta($xy) -text $x -justify $tj($xy) -tags gridline}}
}
}
#> mat frame
#. -bd 3 #w 384 #h 144 #bg white #ln purple
#. #Xa 123 #Xb 2000 #Ya 0 #Yb 127 #qXv 125 #qYv 1
#. @list ::ix::mat_add .- .| {.#1} .#2 .#3 .#4
#. @add ::ix::mat_add .- .| {.#1} .#2 .#3 .#4
puts "mat .- .|"
::ix::mat_new .- .| .#w .#h .#bg .#ln .#Xa .#Xb .#Ya .#Yb .#qXv .#qYv
--- NEW FILE: mat-demo.pd ---
#N canvas 25 203 920 777 12;
#X obj 30 0 widget mat n1 #w 881 #bg white #divX 8 #divY 5 #h 740 #Yb
7;
#X msg 1080 -23 -height 26 -width 26 -bg gray95;
#X msg 32 -22 redefine;
#X msg 242 -21 #w \$1;
#X msg 206 -22 #h \$1;
#X floatatom 172 -23 5 0 0 0 - - -;
#X floatatom 140 -21 5 0 0 0 - - -;
#X msg 329 -20 #Yb \$1;
#X floatatom 380 -18 5 0 0 0 - - -;
#X connect 2 0 0 0;
#X connect 3 0 0 0;
#X connect 4 0 0 0;
#X connect 5 0 3 0;
#X connect 6 0 4 0;
#X connect 7 0 0 0;
#X connect 8 0 7 0;
More information about the Pd-cvs
mailing list