aboutsummaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorlecoanet2003-03-30 09:09:44 +0000
committerlecoanet2003-03-30 09:09:44 +0000
commit839c6cd06b3fccc2e6dc227746e58b3544a70b22 (patch)
tree9a1ca213fcdf9dc4e4dfa93d6b52698f1b0cf28b /demos
parentd6a7dbb3a6090cc7d8007237f0b4f75c1d3f0112 (diff)
downloadtkzinc-839c6cd06b3fccc2e6dc227746e58b3544a70b22.zip
tkzinc-839c6cd06b3fccc2e6dc227746e58b3544a70b22.tar.gz
tkzinc-839c6cd06b3fccc2e6dc227746e58b3544a70b22.tar.bz2
tkzinc-839c6cd06b3fccc2e6dc227746e58b3544a70b22.tar.xz
Mise � jour interm�diaire
Diffstat (limited to 'demos')
-rw-r--r--demos/contours.tcl92
-rw-r--r--demos/groupsInAtcStrips.tcl2
-rw-r--r--demos/iconTransform.tcl18
-rw-r--r--demos/tiger.tcl5
-rw-r--r--demos/tkZincLogo.tcl24
-rw-r--r--demos/zinc-widget9
6 files changed, 77 insertions, 73 deletions
diff --git a/demos/contours.tcl b/demos/contours.tcl
index 07fa3c3..ea3aab3 100644
--- a/demos/contours.tcl
+++ b/demos/contours.tcl
@@ -82,16 +82,17 @@ $w.zinc translate $curve3 -130 0
# cloning curve0 as curve4 and moving it slightly
set curve4 [$w.zinc clone $curve0 -visible 1 -fillcolor grey50 -tags grouped -fillrule positive]
- # the tag "grouped" is used for both curve4 and
- # a handle (see just below)
- # It is used for translating both easily
+# the tag "grouped" is used for both curve4 and
+# a handle (see just below)
+# It is used for translating both easily
set index 2; ## index of the vertex associated to the handle
set coord [$w.zinc coords $curve4 0 $index]
set x [lindex $coord 0]
set y [lindex $coord 1]
-set handle [$w.zinc add rectangle 1 "[expr $x-5] [expr $y-5] [expr $x+5] [expr $y+5]" -fillcolor black -filled 1 -tags {grouped}]
+set handle [$w.zinc add rectangle 1 "[expr $x-5] [expr $y-5] [expr $x+5] [expr $y+5]" \
+ -fillcolor black -filled 1 -tags {grouped}]
# adding a 'difference' contour to the curve4
@@ -121,71 +122,68 @@ $w.zinc raise $curve1
# adding drag and drop callback to each visible curve!
foreach item "$curve1 $curve2 $curve3 $curve4" {
# Some bindings for dragging the items
- $w.zinc bind $item <1> "itemStartDrag $item %x %y"
- $w.zinc bind $item <B1-Motion> "itemDrag $item %x %y"
- # <ButtonRelease-1> release
+ $w.zinc bind $item <ButtonPress-1> "press $item motion %x %y"
+ $w.zinc bind $item <ButtonRelease-1> release
}
# adding drag and drop on curve4 which also moves handle
-$w.zinc bind $curve4 <ButtonPress-1> {press $curve4 motionWithHandle}
+$w.zinc bind $curve4 <ButtonPress-1> "press $curve4 motionWithHandle %x %y"
$w.zinc bind $curve4, <ButtonRelease-1> release
# adding drag and drop on handle which also modify curve4
-$w.zinc bind handle <ButtonPress-1> {press $handle moveHandle}
-$w.zinc bind handle <ButtonRelease-1> release
+$w.zinc bind $handle <ButtonPress-1> "press $handle moveHandle %x %y"
+$w.zinc bind $handle <ButtonRelease-1> release
# callback for starting a drag
-set x_orig ""
-set y_orig ""
+set xOrig 0
+set yOrig 0
-proc itemStartDrag {item x y} {
- global x_orig y_orig
- set x_orig $x
- set y_orig $y
+proc press {item action x y} {
+ global w xOrig yOrig
+
+ puts "item $item"
+ set xOrig $x
+ set yOrig $y
+ bind $w.zinc <Motion> "$action $item %x %y"
}
# Callback for moving an item
-proc itemDrag {item x y} {
- global x_orig y_orig
- global w
- $w.zinc translate $item [expr $x-$x_orig] [expr $y-$y_orig];
- set x_orig $x;
- set y_orig $y;
+proc motion {item x y} {
+ global w xOrig yOrig
+
+ $w.zinc translate $item [expr $x - $xOrig] [expr $y - $yOrig]
+ set xOrig $x
+ set yOrig $y
}
# Callback for moving an item and its handle
-proc motionWithHandle {item} {
- global x_orig
- global y_orig
- set ev [$w.zinc XEvent]
- set x_orig $ev->x;
- set y_orig $ev->y;
-
- set tag [$w.zinc itemcget $item -tags]
- $w.zinc translate $tag [epxr $x-$x_orig] [expr $y-$y_orig]
- set x_orig $x;
- set y_orig $y;
+proc motionWithHandle {item x y} {
+ global w xOrig yOrig
+
+ set tag [lindex [$w.zinc itemcget $item -tags] 0]
+ $w.zinc translate $tag [expr $x-$xOrig] [expr $y-$yOrig]
+ set xOrig $x;
+ set yOrig $y;
}
# Callback for moving the handle and modifying curve4
# this code is far from being generic. Only for demonstrating how we can
# modify a contour with a unique handle!
-proc moveHandle {handle} {
- global x_orig
- global y_orig
- set ev [$w.zinc XEvent]
- set x_orig $ev->x;
- set y_orig $ev->y;
-
- $w.zinc translate $handle [expr $x-$x_orig] [expr $y-$y_orig];
-
- set ($vertxX,$vertxY) [$w.zinc coords $curve4 0 $index]
- $w.zinc coords $curve4 0 $index "[expr $vertxX+($x-$x_orig)] [expr $vertxY+($y-$y_orig)]"
- set x_orig $x
- set y_orig $y
+proc moveHandle {handle x y} {
+ global w xOrig yOrig curve4 index
+
+ puts "$handle $x $y"
+ $w.zinc translate $handle [expr $x - $xOrig] [expr $y - $yOrig];
+
+ foreach {vertxX vertxY} [$w.zinc coords $curve4 0 $index] break
+ $w.zinc coords $curve4 0 $index "[expr $vertxX+($x-$xOrig)] [expr $vertxY+($y-$yOrig)]"
+ set xOrig $x
+ set yOrig $y
}
proc release {} {
- $w.zinc Tk::bind('<Motion>', '');
+ global w
+
+ bind $w.zinc <Motion> {}
}
diff --git a/demos/groupsInAtcStrips.tcl b/demos/groupsInAtcStrips.tcl
index fb6bdd0..578b688 100644
--- a/demos/groupsInAtcStrips.tcl
+++ b/demos/groupsInAtcStrips.tcl
@@ -70,7 +70,7 @@ pack $w.buttons.dismiss $w.buttons.code -side left -expand 1
text $w.text -relief sunken -borderwidth 2 -height 5
pack $w.text -expand yes -fill both
-$w.text insert end {'These fake air Traffic Control electronic strips illustrates
+$w.text insert end {These fake air Traffic Control electronic strips illustrates
the use of groups for an advanced graphic design.
The following interactions are possible:
"drag&drop button1" on the callsign.
diff --git a/demos/iconTransform.tcl b/demos/iconTransform.tcl
index 7f245dc..4d00bad 100644
--- a/demos/iconTransform.tcl
+++ b/demos/iconTransform.tcl
@@ -11,7 +11,7 @@ set w .iconTransform
catch {destroy $w}
toplevel $w
wm title $w "Zinc icon scale/rotate Demonstration"
-wm iconname $w zincTransform
+wm iconname $w iconTransform
set defaultfont "-adobe-helvetica-bold-r-normal-*-120-*-*-*-*-*-*"
@@ -33,9 +33,9 @@ pack $w.text -expand yes -fill both
$w.text insert end {This demo needs openGL for rescaling/rotating the icon
You can transform this earth gif image with your mouse:
- Drag-Button 1 for zooming the earth,
- Drag-Button 2 for rotating the earth,
- Drag-Button 3 for moving the earth,
+ Drag-Button 1 for moving the earth,
+ Drag-Button 2 for zooming the earth,
+ Drag-Button 3 for rotating the earth,
Shift-Drag-Button 1 for modifying the earth transparency.}
@@ -64,6 +64,8 @@ bind $w.zinc <ButtonPress-1> "press motion %x %y"
bind $w.zinc <ButtonRelease-1> release
bind $w.zinc <ButtonPress-2> "press zoom %x %y"
bind $w.zinc <ButtonRelease-2> release
+bind $w.zinc <ButtonPress-3> "press mouseRotate %x %y"
+bind $w.zinc <ButtonRelease-3> release
#
# Controls for alpha and gradient
@@ -123,7 +125,7 @@ proc mouseRotate {x y} {
global w curAngle topGroup
set lAngle [expr atan2($y, $x)]
- $w.zinc rotate $topGroup [expr -($lAngle - $curAngle)]
+ $w.zinc rotate $topGroup [expr $lAngle - $curAngle]
set curAngle $lAngle
}
@@ -134,11 +136,11 @@ proc release {} {
}
proc modifyAlpha {x y} {
- global w
+ global w topGroup
set xRate [expr double($x) / [$w.zinc cget -width]]
set xRate [expr ($xRate < 0) ? 0 : ($xRate > 1) ? 1 : $xRate]
- set alpha [expr $xRate * 100]
+ set alpha [expr int($xRate * 100)]
- $w.zinc itemconfigure $group -alpha $alpha
+ $w.zinc itemconfigure $topGroup -alpha $alpha
}
diff --git a/demos/tiger.tcl b/demos/tiger.tcl
index b0ac265..c494c7b 100644
--- a/demos/tiger.tcl
+++ b/demos/tiger.tcl
@@ -534,6 +534,8 @@ bind $w.zinc <ButtonPress-1> "press motion %x %y"
bind $w.zinc <ButtonRelease-1> release
bind $w.zinc <ButtonPress-2> "press zoom %x %y"
bind $w.zinc <ButtonRelease-2> release
+bind $w.zinc <ButtonPress-3> "press mouseRotate %x %y"
+bind $w.zinc <ButtonRelease-3> release
set curX 0
@@ -577,7 +579,6 @@ proc zoom {x y} {
}
set sx [expr 1.0 + (double($x - $curX) / $maxX)]
set sy [expr 1.0 + (double($y - $curY) / $maxY)]
- puts "x: $x cur: $curX max: $maxX $sx"
$w.zinc scale $topGroup $sx $sx
set curX $x
set curY $y
@@ -587,7 +588,7 @@ proc mouseRotate {x y} {
global w curAngle topGroup
set lAngle [expr atan2($y, $x)]
- $w.zinc rotate $topGroup [expr -($lAngle - $curAngle)]
+ $w.zinc rotate $topGroup [expr $lAngle - $curAngle]
set curAngle $lAngle
}
diff --git a/demos/tkZincLogo.tcl b/demos/tkZincLogo.tcl
index 6db4031..2e72f36 100644
--- a/demos/tkZincLogo.tcl
+++ b/demos/tkZincLogo.tcl
@@ -34,7 +34,7 @@ pack $w.buttons.dismiss $w.buttons.code -side left -expand 1
#######################
####################
-text $w.text -relief sunken -borderwidth 2 -height 5
+text $w.text -relief sunken -borderwidth 2 -height 7
pack $w.text -expand yes -fill both
$w.text insert end {This tkZinc logo should used openGL for a correct rendering!
@@ -53,9 +53,9 @@ zinc $w.zinc -width 350 -height 250 -render 1 -font 10x20 \
-borderwidth 3 -relief sunken
pack $w.zinc
-set group [$w.zinc add group 1]
+set topGroup [$w.zinc add group 1]
-set logo [zincLogo::create $w.zinc $group 800 40 70 0.6 0.6]
+set logo [zincLogo::create $w.zinc $topGroup 800 40 70 0.6 0.6]
#
# Controls for the window transform.
@@ -64,6 +64,8 @@ bind $w.zinc <ButtonPress-1> "press motion %x %y"
bind $w.zinc <ButtonRelease-1> release
bind $w.zinc <ButtonPress-2> "press zoom %x %y"
bind $w.zinc <ButtonRelease-2> release
+bind $w.zinc <ButtonPress-3> "press mouseRotate %x %y"
+bind $w.zinc <ButtonRelease-3> release
#
# Controls for alpha and gradient
@@ -122,10 +124,10 @@ proc zoom {x y} {
}
proc mouseRotate {x y} {
- global w curAngle topGroup
+ global w curAngle logo
set lAngle [expr atan2($y, $x)]
- $w.zinc rotate $topGroup [expr -($lAngle - $curAngle)]
+ $w.zinc rotate $logo [expr $lAngle - $curAngle]
set curAngle $lAngle
}
@@ -136,21 +138,21 @@ proc release {} {
}
proc modifyAlpha {x y} {
- global w
+ global w topGroup
set xRate [expr double($x) / [$w.zinc cget -width]]
set xRate [expr ($xRate < 0) ? 0 : ($xRate > 1) ? 1 : $xRate]
- set alpha [expr $xRate * 100]
+ set alpha [expr int($xRate * 100)]
- $w.zinc itemconfigure $group -alpha $alpha
+ $w.zinc itemconfigure $topGroup -alpha $alpha
}
proc modifyGradient {x y} {
global w
- set yRate [expr double($ly) / [$w.zinc cget -height]]
+ set yRate [expr double($y) / [$w.zinc cget -height]]
set yRate [expr ($yRate < 0) ? 0 : ($yRate > 1) ? 1 : $yRate]
- set gradientPercent [expr int($yRate * 100)]
+ set gradPercent [expr int($yRate * 100)]
- $w.zinc itemconfigure letters -fillcolor => "=axial 270|#ffffff;100 0 28|#66848c;100 $gradientpercent|#7192aa;100 100"
+ $w.zinc itemconfigure letters -fillcolor "=axial 270|#ffffff;100 0 28|#66848c;100 $gradPercent|#7192aa;100 100"
}
diff --git a/demos/zinc-widget b/demos/zinc-widget
index d468e3e..f09baa3 100644
--- a/demos/zinc-widget
+++ b/demos/zinc-widget
@@ -145,10 +145,11 @@ set lastLine ""
.t insert end "\n" {} "Use of open GL\n" title
.t insert end "1. The TkZinc Logo.\n" {demo demo-tkZincLogo}
.t insert end "2. Applying transformations to an icon.\n" {demo demo-iconTransform}
-.t insert end "3. Axial color variation on the X axis.\n" {demo demo-colorX}
-.t insert end "4. Axial color variation on the Y axis.\n" {demo demo-colorY}
-.t insert end "5. Circular color variation.\n" {demo demo-colorCircular}
-.t insert end "6. The triangles item.\n" {demo demo-triangles}
+.t insert end "3. Using the alpha information from an image (Need Img ext.).\n" {demo demo-photoAlpha}
+.t insert end "4. Axial color variation on the X axis.\n" {demo demo-colorX}
+.t insert end "5. Axial color variation on the Y axis.\n" {demo demo-colorY}
+.t insert end "6. Circular color variation.\n" {demo demo-colorCircular}
+.t insert end "7. The triangles item.\n" {demo demo-triangles}
.t configure -state disabled
focus .s