From 50d14214169c405aa823640e604885a259b4c0b4 Mon Sep 17 00:00:00 2001 From: lecoanet Date: Tue, 23 Mar 2004 08:23:38 +0000 Subject: Backup the previous patch following addition of -position in Groups. --- demos/magicLens.tcl | 55 +++++++++++++++++++++-------------------------------- 1 file changed, 22 insertions(+), 33 deletions(-) (limited to 'demos') diff --git a/demos/magicLens.tcl b/demos/magicLens.tcl index 0ff19e2..9fa8482 100644 --- a/demos/magicLens.tcl +++ b/demos/magicLens.tcl @@ -131,21 +131,14 @@ proc LensStart {x y} { proc LensMove {x y} { global dx dy zoom zinc infoView - set dx [expr $x + $dx] - set dy [expr $y + $dy] - - foreach {lx ly} [$zinc itemcget lens -position] break - set lx [expr $lx + $dx] - set ly [expr $ly + $dy] - - $zinc itemconfigure lens -position [list $lx $ly] - $zinc translate lenszone $dx $dy - - $zinc itemconfigure $infoView -position [list [expr $lx * (1 - $zoom)] \ - [expr $ly * (1 - $zoom)]] + $zinc translate current [expr $x + $dx] [expr $y + $dy] + $zinc translate lenszone [expr $x + $dx] [expr $y + $dy] + set dx [expr 0 - $x] + set dy [expr 0 - $y] - set dx [expr -$x] - set dy [expr -$y] + foreach {lx ly} [$zinc coords lens 0 0] break + $zinc coords $infoView [list [expr $lx * (1 - $zoom)] \ + [expr $ly * (1 - $zoom)]] } @@ -168,15 +161,11 @@ proc LensTranslate {way} { down {set dy 10} } - foreach {lx ly} [$zinc itemcget lens -position] break - set lx [expr $lx + $dx] - set ly [expr $ly + $dy] - - $zinc itemconfigure lens -position [list $lx $ly] + $zinc translate lens $dx $dy $zinc translate lenszone $dx $dy - - $zinc itemconfigure $infoView -position [list [expr $lx * (1 - $zoom)] \ - [expr $ly * (1 - $zoom)]] + foreach {lx ly} [$zinc coords lens 0 0] break + $zinc coords $infoView [list [expr $lx * (1 - $zoom)] \ + [expr $ly * (1 - $zoom)]] } @@ -208,11 +197,10 @@ set lensView [$zinc add group 1 -priority 200] set infoView [$zinc add group $lensView] set zoom 1.20 -#set zoom 1.0 $zinc scale $infoView $zoom $zoom $zinc add rectangle $infoView {{0 0} {1000 900}} \ - -filled 1 -fillcolor \#000000 -tile $lensTexture -linewidth 2 + -filled 1 -fillcolor \#000000 -tile $lensTexture -linewidth 0 set x 60 for {set i 0} {$i < 12} {incr i} { @@ -254,32 +242,33 @@ for {set i 0} {$i < 12} {incr i} { } # Create intermediate steps between colors (saturation -> desaturation) - for {set c 0} {$c < 11} {incr c} { + for {set c 0} {$c < 11} {incr c} { # Color of the current step set color [lindex $znColors $c] - + # Create a zinc item for the color set sample [$zinc clone $refItem -fillcolor $color] $zinc translate $sample 0 [expr 65*($c+1)] - + # Add its shape to the multi-contours curve $zinc contour $gradBar add 1 $sample - + # Move the item to the info group $zinc chggroup $sample $lGroup - + # Text of label (% saturation + ZnColor) set txtColor "[expr ((10 - $c)*10)]%\n$color" $zinc add text $lGroup -priority 200 -position [list 0 [expr ($c + 1)* 65]] \ -text $txtColor -anchor center -alignment center -font $font8 -spacing 2 \ -composescale 0 - } + } incr x 80 } # Create the lens itself -set lensGroup [$zinc add group 1 -priority 300 -atomic 1 -position {300 110} -tags lens] +set lensGroup [$zinc add group 1 -priority 300 -atomic 1 -tags lens] +$zinc coords $lensGroup {300 110} set dx 0 set dy 0 LensMove 0 0 @@ -297,8 +286,8 @@ $zinc itemconfigure $lensView -clip $lensZone set consigne [$zinc add text 1 -position {30 840} -font $font8 -alignment left \ -color \#ffffff -spacing 2 \ -text ", , and keys or -# Move the Magic Color Lens behind the color gradiants -# to see the ZnColor value of Hue/saturation"] +Move the Magic Color Lens behind the color gradiants +to see the ZnColor value of Hue/saturation"] set cClone [$zinc clone $consigne -font $font9b] $zinc chggroup $cClone $infoView -- cgit v1.1