diff options
author | carmen rocco <ix9@users.sourceforge.net> | 2005-05-16 12:23:50 +0000 |
---|---|---|
committer | carmen rocco <ix9@users.sourceforge.net> | 2005-05-16 12:23:50 +0000 |
commit | 2ac7689dc357bb5874c585a8138fa4b4c9057985 (patch) | |
tree | 9dbcfc4f04e0bb722f089945c2645ee8a2d0a530 /extensions/gui/ix | |
parent | a57fbdf76fde94f2199b1e064cde750bee480c98 (diff) |
mat (not done)
----------------------------------------------------------------------
svn path=/trunk/; revision=2980
Diffstat (limited to 'extensions/gui/ix')
-rwxr-xr-x | extensions/gui/ix/mat-demo.pd | 18 | ||||
-rwxr-xr-x | extensions/gui/ix/mat.wid | 81 |
2 files changed, 99 insertions, 0 deletions
diff --git a/extensions/gui/ix/mat-demo.pd b/extensions/gui/ix/mat-demo.pd new file mode 100755 index 00000000..405028e3 --- /dev/null +++ b/extensions/gui/ix/mat-demo.pd @@ -0,0 +1,18 @@ +#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; diff --git a/extensions/gui/ix/mat.wid b/extensions/gui/ix/mat.wid new file mode 100755 index 00000000..690d22cc --- /dev/null +++ b/extensions/gui/ix/mat.wid @@ -0,0 +1,81 @@ +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
|