aboutsummaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorlecoanet2004-03-10 12:03:46 +0000
committerlecoanet2004-03-10 12:03:46 +0000
commit213a7ed0ec23f913e3d7f18c15d4e863ee75e0cd (patch)
treee196da5e25b524fe97d480877a9ea40dfa4f0494 /demos
parent7cf0eb9b7d071512622e3a33675565dd8f471d59 (diff)
downloadtkzinc-213a7ed0ec23f913e3d7f18c15d4e863ee75e0cd.zip
tkzinc-213a7ed0ec23f913e3d7f18c15d4e863ee75e0cd.tar.gz
tkzinc-213a7ed0ec23f913e3d7f18c15d4e863ee75e0cd.tar.bz2
tkzinc-213a7ed0ec23f913e3d7f18c15d4e863ee75e0cd.tar.xz
Fixed an incorrect behavior caused by the changes in group
coords / -position behavior. The code used both translate coords and scale.
Diffstat (limited to 'demos')
-rw-r--r--demos/magicLens.tcl73
1 files changed, 42 insertions, 31 deletions
diff --git a/demos/magicLens.tcl b/demos/magicLens.tcl
index 251a902..0ff19e2 100644
--- a/demos/magicLens.tcl
+++ b/demos/magicLens.tcl
@@ -131,14 +131,21 @@ proc LensStart {x y} {
proc LensMove {x y} {
global dx dy zoom zinc infoView
- $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 + $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
- foreach {lx ly} [$zinc coords lens 0 0] break
- $zinc coords $infoView [list [expr $lx * (1 - $zoom)] \
- [expr $ly * (1 - $zoom)]]
+ $zinc itemconfigure $infoView -position [list [expr $lx * (1 - $zoom)] \
+ [expr $ly * (1 - $zoom)]]
+
+ set dx [expr -$x]
+ set dy [expr -$y]
}
@@ -161,11 +168,15 @@ proc LensTranslate {way} {
down {set dy 10}
}
- $zinc translate lens $dx $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
- foreach {lx ly} [$zinc coords lens 0 0] break
- $zinc coords $infoView [list [expr $lx * (1 - $zoom)] \
- [expr $ly * (1 - $zoom)]]
+
+ $zinc itemconfigure $infoView -position [list [expr $lx * (1 - $zoom)] \
+ [expr $ly * (1 - $zoom)]]
}
@@ -197,10 +208,11 @@ 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 0
+ -filled 1 -fillcolor \#000000 -tile $lensTexture -linewidth 2
set x 60
for {set i 0} {$i < 12} {incr i} {
@@ -242,33 +254,32 @@ for {set i 0} {$i < 12} {incr i} {
}
# Create intermediate steps between colors (saturation -> desaturation)
- for {set c 0} {$c < 11} {incr c} {
- # Color of the current step
- set color [lindex $znColors $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)]
+ # 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
+ # 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
+ # 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 \
+ # 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 -tags lens]
-$zinc coords $lensGroup {300 110}
+set lensGroup [$zinc add group 1 -priority 300 -atomic 1 -position {300 110} -tags lens]
set dx 0
set dy 0
LensMove 0 0
@@ -286,8 +297,8 @@ $zinc itemconfigure $lensView -clip $lensZone
set consigne [$zinc add text 1 -position {30 840} -font $font8 -alignment left \
-color \#ffffff -spacing 2 \
-text "<Up>, <Down>, <Left> and <Right> keys or <Mouse Drag>
-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