From 9f0d489e9cda59a8ed026be96fa56f9ecc1a33f7 Mon Sep 17 00:00:00 2001 From: lecoanet Date: Fri, 7 May 2004 15:31:01 +0000 Subject: Switched from pack to grid; Demos are put in a namespace; No more name aliases for fonts --- demos/allOptions.tcl | 2 +- demos/atomicGroups.tcl | 4 +- demos/clipping.tcl | 4 +- demos/colorCircular.tcl | 81 +++++---- demos/colorX.tcl | 54 +++--- demos/colorY.tcl | 52 +++--- demos/contours.tcl | 4 +- demos/curveBezier.tcl | 5 +- demos/fillRule.tcl | 5 +- demos/groupsPriority.tcl | 8 +- demos/iconTransform.tcl | 262 ++++++++++++++------------- demos/labelformat.tcl | 4 +- demos/lines.tcl | 16 +- demos/photoAlpha.tcl | 246 ++++++++++++++------------ demos/reliefs.tcl | 451 ++++++++++++++++++++++++----------------------- demos/tiger.tcl | 4 +- demos/tkZincLogo.tcl | 280 +++++++++++++++-------------- demos/transforms.tcl | 4 +- demos/triangles.tcl | 60 ++++--- demos/windowContours.tcl | 9 +- 20 files changed, 819 insertions(+), 736 deletions(-) (limited to 'demos') diff --git a/demos/allOptions.tcl b/demos/allOptions.tcl index 8ccbec2..46b60c6 100644 --- a/demos/allOptions.tcl +++ b/demos/allOptions.tcl @@ -28,7 +28,7 @@ namespace eval allOptions { # Creating the zinc widget - zinc $w.zinc -width 1 -height 1 -font 10x20 -borderwidth 0 -relief sunken + zinc $w.zinc -width 1 -height 1 -borderwidth 0 -relief sunken pack $w.zinc # Creating an instance of every item type diff --git a/demos/atomicGroups.tcl b/demos/atomicGroups.tcl index a42593c..2bf782b 100644 --- a/demos/atomicGroups.tcl +++ b/demos/atomicGroups.tcl @@ -12,12 +12,12 @@ namespace eval atomicGroups { wm title $w "Zinc Atomicity Demonstration" wm iconname $w "Atomic" - variable defaultfont [font create -family Helvetica -size 10 -weight bold] + variable defaultfont [font create -family Helvetica -size 14 -weight normal] grid [button $w.dismiss -text Dismiss -command "destroy $w"] -row 6 -column 0 -pady 10 grid [button $w.code -text "See Code" -command "showCode $w"] -row 6 -column 1 -pady 10 - grid [zinc $w.zinc -width 500 -height 350 -font 10x20 -borderwidth 0] \ + grid [zinc $w.zinc -width 500 -height 350 -font $defaultfont -borderwidth 0] \ -row 0 -column 0 -columnspan 2 -sticky news grid columnconfigure $w 0 -weight 1 grid columnconfigure $w 1 -weight 1 diff --git a/demos/clipping.tcl b/demos/clipping.tcl index e7346fa..4d0fa28 100644 --- a/demos/clipping.tcl +++ b/demos/clipping.tcl @@ -12,12 +12,12 @@ namespace eval clippingDemo { wm title $w "Zinc Clipping Demonstration" wm iconname $w "Clipping" - variable defaultfont [font create -family Helvetica -size 10 -weight bold] + variable defaultfont [font create -family Helvetica -size 14 -weight normal] grid [button $w.dismiss -text Dismiss -command "destroy $w"] -row 2 -column 0 -pady 10 grid [button $w.code -text "See Code" -command "showCode $w"] -row 2 -column 1 -pady 10 - grid [zinc $w.zinc -width 700 -height 600 -font 10x20 -borderwidth 3 \ + grid [zinc $w.zinc -width 700 -height 600 -font $defaultfont -borderwidth 3 \ -relief sunken] -row 0 -column 0 -columnspan 2 -sticky news grid columnconfigure $w 0 -weight 1 grid columnconfigure $w 1 -weight 1 diff --git a/demos/colorCircular.tcl b/demos/colorCircular.tcl index 63041c2..e829fd8 100644 --- a/demos/colorCircular.tcl +++ b/demos/colorCircular.tcl @@ -5,56 +5,59 @@ if {![info exists zincDemo]} { error "This script should be run from the zinc-widget demo." } -set w .colorCircular -catch {destroy $w} -toplevel $w -wm title $w "Zinc Color Circular Demonstration" -wm iconname $w "Color Circular" - -frame $w.buttons -pack $w.buttons -side bottom -fill x -pady 2m -button $w.buttons.dismiss -text Dismiss -command "destroy $w" -button $w.buttons.code -text "See Code" -command "showCode $w" -pack $w.buttons.dismiss $w.buttons.code -side left -expand 1 - -set defaultfont [font create -family Helvetica -size 10 -weight bold] - -zinc $w.zinc -width 700 -height 600 -borderwidth 3 -relief sunken -render 1 -pack $w.zinc - -$w.zinc add rectangle 1 {10 10 80 80} -fillcolor {=radial 50 50|red|blue} -filled 1 -$w.zinc add text 1 -font $defaultfont -text {Radial variation from non-transparent red to non-transparent blue in a square. +namespace eval colorCircular { + variable w .colorCircular + catch {destroy $w} + toplevel $w + wm title $w "Zinc Color Circular Demonstration" + wm iconname $w "Color Circular" + + grid [button $w.dismiss -text Dismiss -command "destroy $w"] -row 2 -column 0 -pady 10 + grid [button $w.code -text "See Code" -command "showCode $w"] -row 2 -column 1 -pady 10 + + variable defaultfont [font create -family Helvetica -size 14 -weight normal] + + grid [zinc $w.zinc -width 700 -height 600 -borderwidth 3 -relief sunken -render 1] \ + -row 1 -column 0 -columnspan 2 -sticky news + grid columnconfigure $w 0 -weight 1 + grid columnconfigure $w 1 -weight 1 + grid rowconfigure $w 1 -weight 2 + + $w.zinc add rectangle 1 {10 10 80 80} -fillcolor {=radial 50 50|red|blue} -filled 1 + $w.zinc add text 1 -font $defaultfont -text {Radial variation from non-transparent red to non-transparent blue in a square. The gradient starts in the lower right corner.} -anchor nw -position {120 20} -$w.zinc add arc 1 {10 110 90 190} -fillcolor {=radial 0 25|red;40|blue;40} -filled 1 + $w.zinc add arc 1 {10 110 90 190} -fillcolor {=radial 0 25|red;40|blue;40} -filled 1 -$w.zinc add text 1 -font $defaultfont -text {Radial variation from 40% transparent red to 40% transparent blue in a disc. + $w.zinc add text 1 -font $defaultfont -text {Radial variation from 40% transparent red to 40% transparent blue in a disc. The gradient starts mid way between the center and the bottom.} \ - -anchor nw -position {120 120} + -anchor nw -position {120 120} -$w.zinc add arc 1 {10 210 90 290} -fillcolor {=radial 0 0|red;40|green;40 50|blue;40} -filled 1 + $w.zinc add arc 1 {10 210 90 290} -fillcolor {=radial 0 0|red;40|green;40 50|blue;40} -filled 1 -$w.zinc add text 1 -font $defaultfont -text {A variation from 40% transparent red to 40% transparent blue + $w.zinc add text 1 -font $defaultfont -text {A variation from 40% transparent red to 40% transparent blue through 40% green in the middle of the disc. The gradient is centered.} \ - -anchor nw -position {120 220} + -anchor nw -position {120 220} -$w.zinc add text 1 -font $defaultfont -text {Two overlapping items filled by a transparent radial gradient on a white background. -On the right three gradient filled ovals, note the warped gradients following the ovals.} -anchor w -position {20 320} + $w.zinc add text 1 -font $defaultfont -anchor w -position {20 320} \ + -text {Two overlapping items filled by a transparent radial gradient on a white background. +On the right three gradient filled ovals, note the warped gradients following the ovals.} -$w.zinc add rectangle 1 {10 340 690 590} -fillcolor white -filled 1 + $w.zinc add rectangle 1 {10 340 690 590} -fillcolor white -filled 1 -$w.zinc add rectangle 1 {20 365 220 565} -fillcolor {=radial 0 0|red;40|green;40 50|blue;40} -filled 1 + $w.zinc add rectangle 1 {20 365 220 565} -fillcolor {=radial 0 0|red;40|green;40 50|blue;40} -filled 1 -$w.zinc add arc 1 {150 365 350 565} -fillcolor {=radial 0 0|yellow;40|black;40 50|cyan;40} -filled 1 + $w.zinc add arc 1 {150 365 350 565} -fillcolor {=radial 0 0|yellow;40|black;40 50|cyan;40} -filled 1 -$w.zinc add arc 1 {280 365 480 565} -fillcolor {=radial 0 0|black;100|black;100 20|mistyrose;40} -filled 1 -linewidth 0 + $w.zinc add arc 1 {280 365 480 565} -fillcolor {=radial 0 0|black;100|black;100 20|mistyrose;40} -filled 1 -linewidth 0 -set warc [$w.zinc add arc 1 {-50 -50 50 50} \ - -fillcolor {=radial -10 16|black;80|blue;20 90 100} -filled 1] -$w.zinc scale $warc 1.5 1 -$w.zinc translate $warc 500 432 + variable warc [$w.zinc add arc 1 {-50 -50 50 50} \ + -fillcolor {=radial -10 16|black;80|blue;20 90 100} -filled 1] + $w.zinc scale $warc 1.5 1 + $w.zinc translate $warc 500 432 -set warc [$w.zinc add arc 1 {-50 -50 50 50} \ - -fillcolor {=radial 0 20|black;70|green;20} -filled 1] -$w.zinc scale $warc 1 1.5 -$w.zinc translate $warc 630 432 + variable warc [$w.zinc add arc 1 {-50 -50 50 50} \ + -fillcolor {=radial 0 20|black;70|green;20} -filled 1] + $w.zinc scale $warc 1 1.5 + $w.zinc translate $warc 630 432 +} diff --git a/demos/colorX.tcl b/demos/colorX.tcl index c93ba35..2a4d8a3 100644 --- a/demos/colorX.tcl +++ b/demos/colorX.tcl @@ -5,38 +5,44 @@ if {![info exists zincDemo]} { error "This script should be run from the zinc-widget demo." } -set w .colorX -catch {destroy $w} -toplevel $w -wm title $w "Zinc Color-x Demonstration" -wm iconname $w "Color X" +namespace eval colorX { + variable w .colorX + catch {destroy $w} + toplevel $w + wm title $w "Zinc Color-x Demonstration" + wm iconname $w "Color X" -frame $w.buttons -pack $w.buttons -side bottom -fill x -pady 2m -button $w.buttons.dismiss -text Dismiss -command "destroy $w" -button $w.buttons.code -text "See Code" -command "showCode $w" -pack $w.buttons.dismiss $w.buttons.code -side left -expand 1 + grid [button $w.dismiss -text Dismiss -command "destroy $w"] -row 2 -column 0 -pady 10 + grid [button $w.code -text "See Code" -command "showCode $w"] -row 2 -column 1 -pady 10 -set defaultfont [font create -family Helvetica -size 10 -weight bold] + variable defaultfont [font create -family Helvetica -size 14 -weight normal] -zinc $w.zinc -width 700 -height 600 -borderwidth 3 -relief sunken -render 1 -pack $w.zinc + grid [zinc $w.zinc -width 700 -height 600 -borderwidth 3 -relief sunken -render 1] \ + -row 1 -column 0 -columnspan 2 -sticky news + grid columnconfigure $w 0 -weight 1 + grid columnconfigure $w 1 -weight 1 + grid rowconfigure $w 1 -weight 2 + + $w.zinc add rectangle 1 {10 10 690 100} -fillcolor {red|blue} -filled 1 -$w.zinc add rectangle 1 {10 10 690 100} -fillcolor {red|blue} -filled 1 + $w.zinc add text 1 -font $defaultfont -anchor nw -position {20 20} \ + -text "A variation from non transparent red to non transparent blue.\n" -$w.zinc add text 1 -font $defaultfont -text "A variation from non transparent red to non transparent blue.\n" -anchor nw -position {20 20} + $w.zinc add rectangle 1 {10 110 690 200} -fillcolor {red;40|blue;40} -filled 1 -$w.zinc add rectangle 1 {10 110 690 200} -fillcolor {red;40|blue;40} -filled 1 + $w.zinc add text 1 -font $defaultfont -anchor nw -position {20 120} \ + -text "A variation from 40%transparent red to 40% transparent blue." -$w.zinc add text 1 -font $defaultfont -text "A variation from 40%transparent red to 40% transparent blue." -anchor nw -position {20 120} + $w.zinc add rectangle 1 {10 210 690 300} -fillcolor {red;40|green;40 50|blue;40} -filled 1 -$w.zinc add rectangle 1 {10 210 690 300} -fillcolor {red;40|green;40 50|blue;40} -filled 1 + $w.zinc add text 1 -font $defaultfont -anchor nw -position {20 220} \ + -text "A variation from 40%transparent red to 40% transparent blue.\nthrough a 40%green on the middle" -$w.zinc add text 1 -font $defaultfont -text "A variation from 40%transparent red to 40% transparent blue.\nthrough a 40%green on the middle" -anchor nw -position {20 220} + $w.zinc add text 1 -font $defaultfont -anchor nw -position {20 320} \ + -text "Two overlaping transparently colored rectangles on a white background" -$w.zinc add text 1 -font $defaultfont -text "Two overlaping transparently colored rectangles on a white background" -anchor nw -position {20 320} + $w.zinc add rectangle 1 {10 340 690 590} -fillcolor white -filled 1 + $w.zinc add rectangle 1 {200 350 500 580} -fillcolor {red;40|green;40 50|blue;40} -filled 1 -$w.zinc add rectangle 1 {10 340 690 590} -fillcolor white -filled 1 -$w.zinc add rectangle 1 {200 350 500 580} -fillcolor {red;40|green;40 50|blue;40} -filled 1 - -$w.zinc add rectangle 1 {10 400 690 500} -fillcolor {yellow;40|black;40 50|cyan;40} -filled 1 + $w.zinc add rectangle 1 {10 400 690 500} -fillcolor {yellow;40|black;40 50|cyan;40} -filled 1 +} diff --git a/demos/colorY.tcl b/demos/colorY.tcl index 7ebd4c8..e1b1f38 100644 --- a/demos/colorY.tcl +++ b/demos/colorY.tcl @@ -5,38 +5,44 @@ if {![info exists zincDemo]} { error "This script should be run from the zinc-widget demo." } -set w .colorY -catch {destroy $w} -toplevel $w -wm title $w "Zinc Color-y Demonstration" -wm iconname $w "Color y" +namespace eval colorY { + variable w .colorY + catch {destroy $w} + toplevel $w + wm title $w "Zinc Color-y Demonstration" + wm iconname $w "Color y" -frame $w.buttons -pack $w.buttons -side bottom -fill x -pady 2m -button $w.buttons.dismiss -text Dismiss -command "destroy $w" -button $w.buttons.code -text "See Code" -command "showCode $w" -pack $w.buttons.dismiss $w.buttons.code -side left -expand 1 + grid [button $w.dismiss -text Dismiss -command "destroy $w"] -row 2 -column 0 -pady 10 + grid [button $w.code -text "See Code" -command "showCode $w"] -row 2 -column 1 -pady 10 -set defaultfont [font create -family Helvetica -size 10 -weight bold] + variable defaultfont [font create -family Helvetica -size 14 -weight normal] -zinc $w.zinc -width 700 -height 600 -borderwidth 3 -relief sunken -render 1 -pack $w.zinc + grid [zinc $w.zinc -width 700 -height 600 -borderwidth 3 -relief sunken -render 1] \ + -row 1 -column 0 -columnspan 2 -sticky news + grid columnconfigure $w 0 -weight 1 + grid columnconfigure $w 1 -weight 1 + grid rowconfigure $w 1 -weight 2 -$w.zinc add rectangle 1 {10 10 690 100} -fillcolor {=axial 90|red|blue} -filled 1 + $w.zinc add rectangle 1 {10 10 690 100} -fillcolor {=axial 90|red|blue} -filled 1 -$w.zinc add text 1 -font $defaultfont -text "A variation from non transparent red to non transparent blue.\n" -anchor nw -position {20 20} + $w.zinc add text 1 -font $defaultfont -anchor nw -position {20 20} \ + -text "A variation from non transparent red to non transparent blue.\n" -$w.zinc add rectangle 1 {10 110 690 200} -fillcolor {=axial 90|red;40|blue;40} -filled 1 + $w.zinc add rectangle 1 {10 110 690 200} -fillcolor {=axial 90|red;40|blue;40} -filled 1 -$w.zinc add text 1 -font $defaultfont -text "A variation from 40%transparent red to 40% transparent blue." -anchor nw -position {20 120} + $w.zinc add text 1 -font $defaultfont -anchor nw -position {20 120} \ + -text "A variation from 40%transparent red to 40% transparent blue." -$w.zinc add rectangle 1 {10 210 690 300} -fillcolor {=axial 90|red;40|green;40 50|blue;40} -filled 1 + $w.zinc add rectangle 1 {10 210 690 300} -fillcolor {=axial 90|red;40|green;40 50|blue;40} -filled 1 -$w.zinc add text 1 -font $defaultfont -text "A variation from 40%transparent red to 40% transparent blue.\nthrough a 40%green on the middle" -anchor nw -position {20 220} + $w.zinc add text 1 -font $defaultfont -anchor nw -position {20 220} \ + -text "A variation from 40%transparent red to 40% transparent blue.\nthrough a 40%green on the middle" -$w.zinc add text 1 -font $defaultfont -text "Two overlaping transparently colored rectangles on a white background" -anchor nw -position {20 320} + $w.zinc add text 1 -font $defaultfont -anchor nw -position {20 320} \ + -text "Two overlaping transparently colored rectangles on a white background" -$w.zinc add rectangle 1 {10 340 690 590} -fillcolor white -filled 1 -$w.zinc add rectangle 1 {200 350 500 580} -fillcolor {=axial 90|red;40|green;40 50|blue;40} -filled 1 + $w.zinc add rectangle 1 {10 340 690 590} -fillcolor white -filled 1 + $w.zinc add rectangle 1 {200 350 500 580} -fillcolor {=axial 90|red;40|green;40 50|blue;40} -filled 1 -$w.zinc add rectangle 1 {10 400 690 500} -fillcolor {=axial 90|yellow;40|black;40 50|cyan;40} -filled 1 + $w.zinc add rectangle 1 {10 400 690 500} -fillcolor {=axial 90|yellow;40|black;40 50|cyan;40} -filled 1 +} diff --git a/demos/contours.tcl b/demos/contours.tcl index a3f941a..4f08fca 100644 --- a/demos/contours.tcl +++ b/demos/contours.tcl @@ -11,7 +11,7 @@ namespace eval contoursDemo { toplevel $w wm title $w "Zinc Curve contours Demonstration" wm iconname $w Curve - + grid [button $w.dismiss -text Dismiss -command "destroy $w"] -row 2 -column 0 -pady 10 grid [button $w.code -text "See Code" -command "showCode $w"] -row 2 -column 1 -pady 10 @@ -30,7 +30,7 @@ The following operations are possible: modifying the grey curve contour." # Creating the zinc widget - grid [zinc $w.zinc -width 600 -height 500 -font 10x20 -borderwidth 3 \ + grid [zinc $w.zinc -width 600 -height 500 -borderwidth 3 \ -relief sunken] -row 1 -column 0 -columnspan 2 -sticky news grid columnconfigure $w 0 -weight 1 grid columnconfigure $w 1 -weight 1 diff --git a/demos/curveBezier.tcl b/demos/curveBezier.tcl index 32245b8..ed1622e 100644 --- a/demos/curveBezier.tcl +++ b/demos/curveBezier.tcl @@ -13,7 +13,7 @@ namespace eval curveBezier { wm title $w "Zinc Curve Bezier Demonstration" wm iconname $w Curve - variable defaultfont [font create -family Helvetica -size 10 -weight bold] + variable defaultfont [font create -family Helvetica -size 14 -weight normal] #variable imagePath [file join $zinc_library demos images] #variable texture [image create photo -file [file join $imagePath paper-grey1.gif]] variable splineColor \#AA0000 @@ -34,8 +34,7 @@ namespace eval curveBezier { You can move the handles to modify the bezier curves } - #zinc $w.zinc -width 700 -height 650 -font 9x15 -borderwidth 0 -tile $texture - grid [zinc $w.zinc -width 700 -height 650 -font 9x15 -borderwidth 0 \ + grid [zinc $w.zinc -width 700 -height 650 -font $defaultfont -borderwidth 0 \ -backcolor \#898A8F] -row 1 -column 0 -columnspan 2 -sticky news grid columnconfigure $w 0 -weight 1 grid columnconfigure $w 1 -weight 1 diff --git a/demos/fillRule.tcl b/demos/fillRule.tcl index f17e19a..8817709 100644 --- a/demos/fillRule.tcl +++ b/demos/fillRule.tcl @@ -12,7 +12,7 @@ namespace eval fillRule { wm title $w "Zinc Fillrule Demonstration" wm iconname $w "Fillrule" - variable defaultfont [font create -family Helvetica -size 10 -weight bold] + variable defaultfont [font create -family Helvetica -size 16 -weight normal] grid [button $w.dismiss -text Dismiss -command "destroy $w"] -row 2 -column 0 -pady 10 grid [button $w.code -text "See Code" -command "showCode $w"] -row 2 -column 1 -pady 10 @@ -29,8 +29,7 @@ namespace eval fillRule { #variable imagePath [file join $zinc_library demos images] #variable texture [image create photo -file [file join $imagePath paper-grey1.gif]] - #zinc $w.zinc -width 550 -height 680 -font 10x20 -borderwidth 0 -tile $texture - grid [zinc $w.zinc -width 550 -height 680 -font 10x20 -borderwidth 0 \ + grid [zinc $w.zinc -width 550 -height 680 -font $defaultfont -borderwidth 0 \ -backcolor \#898A8F] -row 1 -column 0 -columnspan 2 -sticky news grid columnconfigure $w 0 -weight 1 grid columnconfigure $w 1 -weight 1 diff --git a/demos/groupsPriority.tcl b/demos/groupsPriority.tcl index 3b5c296..07bfbb6 100644 --- a/demos/groupsPriority.tcl +++ b/demos/groupsPriority.tcl @@ -13,7 +13,7 @@ namespace eval groupsPriority { wm title $w "Zinc Groups priority Demonstration" wm iconname $w Groups - variable defaultfont [font create -family Helvetica -size 10 -weight bold] + variable defaultfont [font create -family Helvetica -size 14 -weight bold] grid [button $w.dismiss -text Dismiss -command "destroy $w"] -row 2 -column 0 -pady 10 grid [button $w.code -text "See Code" -command "showCode $w"] -row 2 -column 1 -pady 10 @@ -33,7 +33,7 @@ namespace eval groupsPriority { ########################################### variable zinc_width 600 variable zinc_height 500 - grid [zinc $w.zinc -width $zinc_width -height $zinc_height -font 10x20 \ + grid [zinc $w.zinc -width $zinc_width -height $zinc_height -font $defaultfont \ -borderwidth 3 -relief sunken] -row 1 -column 0 -columnspan 2 -sticky news grid columnconfigure $w 0 -weight 1 grid columnconfigure $w 1 -weight 1 @@ -55,7 +55,9 @@ namespace eval groupsPriority { # this small group is for merging together : # the rectangle and the text showing its name set g [$w.zinc add group $group1 -visible 1 -atomic 1 -sensitive 1 -priority $counter] - set rec [$w.zinc add rectangle $g "[expr $centerx-100] [expr $centery-60] [expr $centerx+100] [expr $centery+60]" -fillcolor $color -filled 1] + set rec [$w.zinc add rectangle $g \ + [list [expr $centerx-100] [expr $centery-60] [expr $centerx+100] [expr $centery+60]] \ + -fillcolor $color -filled 1] set txt [$w.zinc add "text" $g -position "$centerx $centery" -text "pri=$counter" -anchor center] diff --git a/demos/iconTransform.tcl b/demos/iconTransform.tcl index 442d7a5..cefffdb 100644 --- a/demos/iconTransform.tcl +++ b/demos/iconTransform.tcl @@ -7,139 +7,151 @@ if {![info exists zincDemo]} { } -set w .iconTransform -catch {destroy $w} -toplevel $w -wm title $w "Zinc icon scale/rotate Demonstration" -wm iconname $w iconTransform - -set defaultfont [font create -family Helvetica -size 10 -weight bold] - -frame $w.buttons -pack $w.buttons -side bottom -fill x -pady 2m -button $w.buttons.dismiss -text Dismiss -command "destroy $w" -button $w.buttons.code -text "See Code" -command "showCode $w" -pack $w.buttons.dismiss $w.buttons.code -side left -expand 1 - - - -########################################### -# Text zone -####################### -#################### - -text $w.text -relief sunken -borderwidth 2 -height 6 -pack $w.text -expand yes -fill both - -$w.text insert end {You can transform this image with your mouse: - Drag-Button 1 for moving, - Drag-Button 2 for zooming, - Drag-Button 3 for rotating, - Shift-Drag-Button 1 for modifying the transparency (OpenGL only).} - - -########################################### -# Zinc -########################################## -zinc $w.zinc -width 350 -height 250 -render 1 -font 10x20 \ - -borderwidth 3 -relief sunken -pack $w.zinc - -set topGroup [$w.zinc add group 1] - -image create photo zincAA -file [file join $zinc_library demos images zinc.gif] - -set zincAA [$w.zinc add icon $topGroup -image zincAA \ - -composescale 1 -composerotation 1] - -$w.zinc add text $topGroup -connecteditem $zincAA \ - -text {try to zoom/resize the banner!} -color white \ - -composescale 1 -composerotation 1 - -# -# Controls for the window transform. -# -bind $w.zinc "press motion %x %y" -bind $w.zinc release -bind $w.zinc "press zoom %x %y" -bind $w.zinc release -bind $w.zinc "press mouseRotate %x %y" -bind $w.zinc release - -# -# Controls for alpha and gradient -# -bind $w.zinc "press modifyAlpha %x %y" -bind $w.zinc release - - -set curX 0 -set curY 0 -set curAngle 0 - -proc press {action x y} { - global w curAngle curX curY - - set curX $x - set curY $y - set curAngle [expr atan2($y, $x)] - bind $w.zinc "$action %x %y" -} - -proc motion {x y} { - global w topGroup curX curY - - foreach {x1 y1 x2 y2} [$w.zinc transform $topGroup \ - [list $x $y $curX $curY]] break - $w.zinc translate $topGroup [expr $x1 - $x2] [expr $y1 - $y2] - set curX $x - set curY $y -} - -proc zoom {x y} { - global w topGroup curX curY - - if {$x > $curX} { - set maxX $x - } else { - set maxX $curX - } - if {$y > $curY} { - set maxY $y - } else { - set maxY $curY +namespace eval iconTransform { + variable w .iconTransform + catch {destroy $w} + toplevel $w + wm title $w "Zinc icon scale/rotate Demonstration" + wm iconname $w iconTransform + + variable defaultfont [font create -family Helvetica -size 16 -weight normal] + + grid [button $w.dismiss -text Dismiss -command "destroy $w"] -row 2 -column 0 -pady 10 + grid [button $w.code -text "See Code" -command "showCode $w"] -row 2 -column 1 -pady 10 + + + ########################################### + # Text zone + ####################### + #################### + + grid [text $w.text -relief sunken -borderwidth 2 -height 6] \ + -row 0 -column 0 -columnspan 2 -sticky ew + + $w.text insert end {You can transform this image with your mouse: + Drag-Button 1 for moving, + Drag-Button 2 for zooming, + Drag-Button 3 for rotating, + Shift-Drag-Button 1 for modifying the transparency (OpenGL only).} + + + ########################################### + # Zinc + ########################################## + grid [zinc $w.zinc -width 350 -height 250 -render 1 -font $defaultfont \ + -borderwidth 3 -relief sunken] -row 1 -column 0 -columnspan 2 -sticky news + grid columnconfigure $w 0 -weight 1 + grid columnconfigure $w 1 -weight 1 + grid rowconfigure $w 1 -weight 2 + + variable topGroup [$w.zinc add group 1] + + image create photo zincAA -file [file join $zinc_library demos images zinc.gif] + + variable zincAA [$w.zinc add icon $topGroup -image zincAA \ + -position {10 10} -composescale 1 -composerotation 1] + + $w.zinc add text $topGroup \ + -text "try to zoom/resize the banner!\nNow works also without openGL ;-)" \ + -color white -composescale 1 -composerotation 1 -position {15 100} + + # + # Controls for the window transform. + # + bind $w.zinc "::iconTransform::press motion %x %y" + bind $w.zinc ::iconTransform::release + bind $w.zinc "::iconTransform::press zoom %x %y" + bind $w.zinc ::iconTransform::release + bind $w.zinc "::iconTransform::press mouseRotate %x %y" + bind $w.zinc ::iconTransform::release + + # + # Controls for alpha and gradient + # + bind $w.zinc "::iconTransform::press modifyAlpha %x %y" + bind $w.zinc ::iconTransform::release + + + variable curX 0 + variable curY 0 + variable curAngle 0 + + proc press {action x y} { + variable w + variable curAngle + variable curX + variable curY + + set curX $x + set curY $y + set curAngle [expr atan2($y, $x)] + bind $w.zinc "::iconTransform::$action %x %y" } - if {($maxX == 0) || ($maxY == 0)} { - return; + + proc motion {x y} { + variable w + variable topGroup + variable curX + variable curY + + foreach {x1 y1 x2 y2} [$w.zinc transform $topGroup \ + [list $x $y $curX $curY]] break + $w.zinc translate $topGroup [expr $x1 - $x2] [expr $y1 - $y2] + set curX $x + set curY $y } - set sx [expr 1.0 + (double($x - $curX) / $maxX)] - set sy [expr 1.0 + (double($y - $curY) / $maxY)] - $w.zinc scale $topGroup $sx $sx - set curX $x - set curY $y -} + proc zoom {x y} { + variable w + variable topGroup + variable curX + variable curY + + if {$x > $curX} { + set maxX $x + } else { + set maxX $curX + } + if {$y > $curY} { + set maxY $y + } else { + set maxY $curY + } + if {($maxX == 0) || ($maxY == 0)} { + return; + } + set sx [expr 1.0 + (double($x - $curX) / $maxX)] + set sy [expr 1.0 + (double($y - $curY) / $maxY)] + $w.zinc scale $topGroup $sx $sx + + set curX $x + set curY $y + } -proc mouseRotate {x y} { - global w curAngle topGroup + proc mouseRotate {x y} { + variable w + variable curAngle + variable topGroup - set lAngle [expr atan2($y, $x)] - $w.zinc rotate $topGroup [expr $lAngle - $curAngle] - set curAngle $lAngle -} + set lAngle [expr atan2($y, $x)] + $w.zinc rotate $topGroup [expr -($lAngle - $curAngle)] + set curAngle $lAngle + } -proc release {} { - global w + proc release {} { + variable w - bind $w.zinc {} -} + bind $w.zinc {} + } -proc modifyAlpha {x y} { - global w topGroup + proc modifyAlpha {x y} { + variable w + variable topGroup - set xRate [expr double($x) / [$w.zinc cget -width]] - set xRate [expr ($xRate < 0) ? 0 : ($xRate > 1) ? 1 : $xRate] - set alpha [expr int($xRate * 100)] + set xRate [expr double($x) / [$w.zinc cget -width]] + set xRate [expr ($xRate < 0) ? 0 : ($xRate > 1) ? 1 : $xRate] + set alpha [expr int($xRate * 100)] - $w.zinc itemconfigure $topGroup -alpha $alpha + $w.zinc itemconfigure $topGroup -alpha $alpha + } } diff --git a/demos/labelformat.tcl b/demos/labelformat.tcl index 2a18854..cab978b 100644 --- a/demos/labelformat.tcl +++ b/demos/labelformat.tcl @@ -12,7 +12,7 @@ namespace eval labelFormat { wm title $w "Zinc Label Format Demonstration" wm iconname $w Label - variable defaultfont [font create -family Helvetica -size 10 -weight bold] + variable defaultfont [font create -family Helvetica -size 16 -weight normal] grid [button $w.dismiss -text Dismiss -command "destroy $w"] -row 2 -column 0 -pady 10 grid [button $w.code -text "See Code" -command "showCode $w"] -row 2 -column 1 -pady 10 @@ -33,7 +33,7 @@ namespace eval labelFormat { ########################################### # Zinc ########################################## - grid [zinc $w.zinc -width 600 -height 500 -font 10x20 -borderwidth 3 \ + grid [zinc $w.zinc -width 600 -height 500 -font $defaultfont -borderwidth 3 \ -relief sunken] -row 1 -column 0 -columnspan 2 -sticky news grid columnconfigure $w 0 -weight 1 grid columnconfigure $w 1 -weight 1 diff --git a/demos/lines.tcl b/demos/lines.tcl index a3f875b..a974e07 100644 --- a/demos/lines.tcl +++ b/demos/lines.tcl @@ -15,15 +15,16 @@ namespace eval linesDemo { grid [button $w.dismiss -text Dismiss -command "destroy $w"] -row 2 -column 0 -pady 10 grid [button $w.code -text "See Code" -command "showCode $w"] -row 2 -column 1 -pady 10 - variable defaultfont [font create -family Helvetica -size 10 -weight bold] + variable defaultfont [font create -family Helvetica -size 14 -weight normal] - grid [zinc $w.zinc -width 700 -height 600 -font 10x20 -borderwidth 3 \ + grid [zinc $w.zinc -width 700 -height 600 -font $defaultfont -borderwidth 3 \ -relief sunken] -row 1 -column 0 -columnspan 2 -sticky news grid columnconfigure $w 0 -weight 1 grid columnconfigure $w 1 -weight 1 grid rowconfigure $w 1 -weight 2 - $w.zinc add text 1 -font $defaultfont -text "A set of lines with different styles of lines and termination\nNB: some attributes such as line styles are not necessarily\navailable with an openGL rendering system" -anchor nw -position {20 20} + $w.zinc add text 1 -font $defaultfont -anchor nw -position {20 20} \ +-text "A set of lines with different styles of lines and termination\nNB: some attributes such as line styles are not necessarily\navailable with an openGL rendering system" $w.zinc add curve 1 {20 100 320 100} $w.zinc add curve 1 {20 120 320 120} -linewidth 20 @@ -45,10 +46,13 @@ namespace eval linesDemo { $w.zinc add curve 1 {340 220 680 220} -linewidth 2 -linestyle dotted - $w.zinc add curve 1 {20 300 140 360 320 300 180 260} -closed 1 -filled 1 -fillpattern "" -fillcolor grey60 -linecolor red -marker AtcSymbol7 -markercolor blue + $w.zinc add curve 1 {20 300 140 360 320 300 180 260} -closed 1 -filled 1 -fillpattern "" \ + -fillcolor grey60 -linecolor red -marker AtcSymbol7 -markercolor blue - $w.zinc add curve 1 {340 300 440 360 620 300 480 260} -closed 1 -linewidth 10 -joinstyle miter -linecolor red + $w.zinc add curve 1 {340 300 440 360 620 300 480 260} -closed 1 -linewidth 10 -joinstyle miter \ + -linecolor red - $w.zinc add curve 1 {400 300 440 330 560 300 480 280} -closed 1 -linewidth 10 -joinstyle round -tile "" -fillcolor grey60 -filled 1 -linecolor red + $w.zinc add curve 1 {400 300 440 330 560 300 480 280} -closed 1 -linewidth 10 -joinstyle round \ + -tile "" -fillcolor grey60 -filled 1 -linecolor red } diff --git a/demos/photoAlpha.tcl b/demos/photoAlpha.tcl index 212ba97..1d1b1b8 100644 --- a/demos/photoAlpha.tcl +++ b/demos/photoAlpha.tcl @@ -5,140 +5,158 @@ if {![info exists zincDemo]} { error "This script should be run from the zinc-widget demo." } -package require Img +namespace eval photoAlpha { + package require Img -set w .photoAlpha -catch {destroy $w} -toplevel $w -wm title $w "Zinc photo transparency Demonstration" -wm iconname $w photoAlpha + variable girl [image create photo -file [file join $zinc_library demos images photoAlpha.png]] + variable texture [image create photo -file [file join $zinc_library demos images stripped_texture.gif]] -set defaultfont [font create -family Helvetica -size 10 -weight bold] + variable w .photoAlpha + catch {destroy $w} + toplevel $w + wm title $w "Zinc photo transparency Demonstration" + wm iconname $w photoAlpha -frame $w.buttons -pack $w.buttons -side bottom -fill x -pady 2m -button $w.buttons.dismiss -text Dismiss -command "destroy $w" -button $w.buttons.code -text "See Code" -command "showCode $w" -pack $w.buttons.dismiss $w.buttons.code -side left -expand 1 + variable defaultfont [font create -family Helvetica -size 16 -weight normal] + grid [button $w.dismiss -text Dismiss -command "destroy $w"] -row 2 -column 0 -pady 10 + grid [button $w.code -text "See Code" -command "showCode $w"] -row 2 -column 1 -pady 10 -########################################### -# Text zone -####################### -#################### + ########################################### + # Text zone + ####################### + #################### -text $w.text -relief sunken -borderwidth 2 -height 7 -pack $w.text -expand yes -fill both + grid [text $w.text -relief sunken -borderwidth 2 -height 7] \ + -row 0 -column 0 -columnspan 2 -sticky ew -$w.text insert end {This demo needs openGL for displaying the photo -with transparent pixels and for rescaling/rotating. - You can transform this png photo with your mouse: - Drag-Button 1 for moving the photo, - Drag-Button 2 for zooming the photo, - Drag-Button 3 for rotating the photo, - Shift-Drag-Button 1 for modifying the global photo transparency.} + $w.text insert end {This demo needs openGL for displaying the photo + with transparent pixels and for rescaling/rotating. + You can transform this png photo with your mouse: + Drag-Button 1 for moving the photo, + Drag-Button 2 for zooming the photo, + Drag-Button 3 for rotating the photo, + Shift-Drag-Button 1 for modifying the global photo transparency.} -image create photo girl -file [file join $zinc_library demos images photoAlpha.png] -image create photo texture -file [file join $zinc_library demos images stripped_texture.gif] - -########################################### -# Zinc -########################################## -zinc $w.zinc -width 350 -height 250 -render 1 -font 10x20 \ - -borderwidth 3 -relief sunken -tile texture -pack $w.zinc - -set topGroup [$w.zinc add group 1] - -set girl [$w.zinc add icon $topGroup -image girl \ - -composescale 1 -composerotation 1] - -# -# Controls for the window transform. -# -bind $w.zinc "press motion %x %y" -bind $w.zinc release -bind $w.zinc "press zoom %x %y" -bind $w.zinc release -bind $w.zinc "press mouseRotate %x %y" -bind $w.zinc release - -# -# Controls for alpha and gradient -# -bind $w.zinc "press modifyAlpha %x %y" -bind $w.zinc release - - -set curX 0 -set curY 0 -set curAngle 0 - -proc press {action x y} { - global w curAngle curX curY - - set curX $x - set curY $y - set curAngle [expr atan2($y, $x)] - bind $w.zinc "$action %x %y" -} - -proc motion {x y} { - global w topGroup curX curY - - foreach {x1 y1 x2 y2} [$w.zinc transform $topGroup \ - [list $x $y $curX $curY]] break - $w.zinc translate $topGroup [expr $x1 - $x2] [expr $y1 - $y2] - set curX $x - set curY $y -} - -proc zoom {x y} { - global w topGroup curX curY - - if {$x > $curX} { - set maxX $x + ########################################### + # Zinc + ########################################## + if { $tcl_platform(platform) eq "unix" } { + zinc $w.zinc -width 350 -height 250 -render 1 -font $defaultfont \ + -borderwidth 3 -relief sunken -tile $texture } else { - set maxX $curX + zinc $w.zinc -width 350 -height 250 -render 1 -font $defaultfont \ + -borderwidth 3 -relief sunken -backcolor \#898A8F } - if {$y > $curY} { - set maxY $y - } else { - set maxY $curY + grid $w.zinc -row 1 -column 0 -columnspan 2 -sticky news + grid columnconfigure $w 0 -weight 1 + grid columnconfigure $w 1 -weight 1 + grid rowconfigure $w 1 -weight 2 + + variable topGroup [$w.zinc add group 1] + + variable girlItem [$w.zinc add icon $topGroup -image $girl \ + -composescale 1 -composerotation 1] + + # + # Controls for the window transform. + # + bind $w.zinc "::photoAlpha::press motion %x %y" + bind $w.zinc ::photoAlpha::release + bind $w.zinc "::photoAlpha::press zoom %x %y" + bind $w.zinc ::photoAlpha::release + bind $w.zinc "::photoAlpha::press mouseRotate %x %y" + bind $w.zinc ::photoAlpha::release + + # + # Controls for alpha and gradient + # + bind $w.zinc "::photoAlpha::press modifyAlpha %x %y" + bind $w.zinc ::photoAlpha::release + + + variable curX 0 + variable curY 0 + variable curAngle 0 + + proc press {action x y} { + variable w + variable curAngle + variable curX + variable curY + + set curX $x + set curY $y + set curAngle [expr atan2($y, $x)] + bind $w.zinc "::photoAlpha::$action %x %y" } - if {($maxX == 0) || ($maxY == 0)} { - return; + + proc motion {x y} { + variable w + variable topGroup + variable curX + variable curY + + foreach {x1 y1 x2 y2} [$w.zinc transform $topGroup \ + [list $x $y $curX $curY]] break + $w.zinc translate $topGroup [expr $x1 - $x2] [expr $y1 - $y2] + set curX $x + set curY $y } - set sx [expr 1.0 + (double($x - $curX) / $maxX)] - set sy [expr 1.0 + (double($y - $curY) / $maxY)] - $w.zinc scale $topGroup $sx $sx - set curX $x - set curY $y -} + proc zoom {x y} { + variable w + variable topGroup + variable curX + variable curY + + if {$x > $curX} { + set maxX $x + } else { + set maxX $curX + } + if {$y > $curY} { + set maxY $y + } else { + set maxY $curY + } + if {($maxX == 0) || ($maxY == 0)} { + return; + } + set sx [expr 1.0 + (double($x - $curX) / $maxX)] + set sy [expr 1.0 + (double($y - $curY) / $maxY)] + $w.zinc scale $topGroup $sx $sx + + set curX $x + set curY $y + } -proc mouseRotate {x y} { - global w curAngle topGroup + proc mouseRotate {x y} { + variable w + variable curAngle + variable topGroup - set lAngle [expr atan2($y, $x)] - $w.zinc rotate $topGroup [expr $lAngle - $curAngle] - set curAngle $lAngle -} + set lAngle [expr atan2($y, $x)] + $w.zinc rotate $topGroup [expr $lAngle - $curAngle] + set curAngle $lAngle + } -proc release {} { - global w + proc release {} { + variable w - bind $w.zinc {} -} + bind $w.zinc {} + } -proc modifyAlpha {x y} { - global w topGroup + proc modifyAlpha {x y} { + variable w + variable topGroup - set xRate [expr double($x) / [$w.zinc cget -width]] - set xRate [expr ($xRate < 0) ? 0 : ($xRate > 1) ? 1 : $xRate] - set alpha [expr int($xRate * 100)] + set xRate [expr double($x) / [$w.zinc cget -width]] + set xRate [expr ($xRate < 0) ? 0 : ($xRate > 1) ? 1 : $xRate] + set alpha [expr int($xRate * 100)] - $w.zinc itemconfigure $topGroup -alpha $alpha + $w.zinc itemconfigure $topGroup -alpha $alpha + } } diff --git a/demos/reliefs.tcl b/demos/reliefs.tcl index c593ee3..67dd3c4 100644 --- a/demos/reliefs.tcl +++ b/demos/reliefs.tcl @@ -5,255 +5,274 @@ if {![info exists zincDemo]} { error "This script should be run from the zinc-widget demo." } -set w .reliefs -catch {destroy $w} -toplevel $w -wm title $w "Zinc Relief Testbed" -wm iconname $w reliefs +namespace eval reliefDemo { + variable w .reliefs + catch {destroy $w} + toplevel $w + wm title $w "Zinc Relief Testbed" + wm iconname $w reliefs -set allReliefs {flat raised sunken groove ridge \ - roundraised roundsunken roundgroove roundridge \ - sunkenrule raisedrule} + variable allReliefs {flat raised sunken groove ridge \ + roundraised roundsunken roundgroove roundridge \ + sunkenrule raisedrule} -set defaultfont [font create -family Helvetica -size 10 -weight bold] + variable defaultfont [font create -family Helvetica -size 14 -weight normal] -frame $w.buttons -pack $w.buttons -side bottom -fill x -pady 2m -button $w.buttons.dismiss -text Dismiss -command "destroy $w" -button $w.buttons.code -text "See Code" -command "showCode $w" -pack $w.buttons.dismiss $w.buttons.code -side left -expand 1 + grid [button $w.dismiss -text Dismiss -command "destroy $w"] -row 2 -column 0 -pady 10 + grid [button $w.code -text "See Code" -command "showCode $w"] -row 2 -column 1 -pady 10 + ########################################### + # Text zone + ####################### + #################### -########################################### -# Text zone -####################### -#################### + grid [text $w.text -relief sunken -borderwidth 2 -height 8 -width 50] \ + -row 0 -column 0 -columnspan 2 -sticky ew -text $w.text -relief sunken -borderwidth 2 -height 8 -width 50 -pack $w.text -expand yes -fill both + $w.text insert end { This demo lets you play with the various relief parameters + on rectangles polygons and arcs. Some reliefs and The smooth relief + capability is only available with openGL. + You can modify the items with your mouse: -$w.text insert end { This demo lets you play with the various relief parameters -on rectangles polygons and arcs. Some reliefs and The smooth relief -capability is only available with openGL. - You can modify the items with your mouse: + Drag-Button 1 for moving Ctrl/Shft-Button 1 for Incr/Decr sides + Drag-Button 2 for zooming Ctrl/Shft-Button 2 for cycling reliefs + Drag-Button 3 for rotating Ctrl/Shft-Button 3 for Incr/Decr border} - Drag-Button 1 for moving Ctrl/Shft-Button 1 for Incr/Decr sides - Drag-Button 2 for zooming Ctrl/Shft-Button 2 for cycling reliefs - Drag-Button 3 for rotating Ctrl/Shft-Button 3 for Incr/Decr border} - -########################################### -# Zinc -########################################## -proc deg2Rad {deg} { - return [expr 3.14159 * $deg / 180.0] -} - -proc rad2Deg {rad} { - return [expr int(fmod(($rad * 180.0 / 3.14159)+360.0, 360.0))] -} - -set bw 4 -set width 60 -set lightAngle 120 -set lightAngleRad [deg2Rad $lightAngle] -set zincSize 500 - -zinc $w.zinc -width $zincSize -height $zincSize -render 1 -font 10x20 \ - -highlightthickness 0 -borderwidth 0 -relief sunken -backcolor lightgray \ - -lightangle $lightAngle -pack $w.zinc -expand t -fill both - -set topGroup [$w.zinc add group 1] - -proc polyPoints { ox oy rad n } { - set step [expr 2 * 3.14159 / $n] - for {set i 0} {$i < $n} {incr i} { - set x [expr $ox + ($rad * cos($i * $step))]; - set y [expr $oy + ($rad * sin($i * $step))]; - lappend coords $x $y; + ########################################### + # Zinc + ########################################## + proc deg2Rad {deg} { + return [expr 3.14159 * $deg / 180.0] } - lappend coords [lindex $coords 0] [lindex $coords 1] - return $coords -} - -proc makePoly {x y bw sides color group} { - global w state allReliefs width - - set relief 2 - - set g [$w.zinc add group $group] - $w.zinc translate $g $x $y - $w.zinc add curve $g [polyPoints 0 0 $width $sides] \ - -relief [lindex $allReliefs $relief] -linewidth $bw \ - -smoothrelief 1 -fillcolor $color -linecolor $color \ - -filled t -tags {subject polygon} - $w.zinc add text $g -anchor center \ - -text [lindex $allReliefs $relief] -tags {subject relief} - $w.zinc add text $g -anchor center -position {0 16} \ - -text $bw -tags {subject bw} - set state($g,sides) $sides - set state($g,relief) $relief - set state($g,bw) $bw - return $g -} - -set poly [makePoly 100 100 $bw 8 lightblue $topGroup] -set poly [makePoly [expr 100 + 2*($width + 10)] 100 $bw 8 tan $topGroup] -set poly [makePoly [expr 100 + 4*($width + 10) ] 100 $bw 8 slateblue $topGroup] - -proc lightCenter {radius angle} { - return [list [expr $radius * (1 + 0.95*cos($angle))] \ - [expr $radius * (1 - 0.95*sin($angle))]] -} - -# -# Place the light at lightAngle on the circle -$w.zinc add arc 1 {-5 -5 5 5} -filled 1 -fillcolor yellow \ - -tags light -priority 10 -eval "$w.zinc translate light [lightCenter [expr $zincSize/2] $lightAngleRad]" - -# -# Controls. -# -$w.zinc bind subject "press motion %x %y" -$w.zinc bind subject release -$w.zinc bind subject "press zoom %x %y" -$w.zinc bind subject release -$w.zinc bind subject "press mouseRotate %x %y" -$w.zinc bind subject release - -$w.zinc bind polygon "incrPolySides 1" -$w.zinc bind polygon "incrPolySides -1" - -$w.zinc bind subject "cycleRelief 1" -$w.zinc bind subject "cycleRelief -1" -$w.zinc bind subject "incrBW 1" -$w.zinc bind subject "incrBW -1" - -$w.zinc bind light "press lightMotion %x %y" -$w.zinc bind light release - -set curX 0 -set curY 0 -set curAngle 0 - -proc press {action x y} { - global w curAngle curX curY + proc rad2Deg {rad} { + return [expr int(fmod(($rad * 180.0 / 3.14159)+360.0, 360.0))] + } - $w.zinc raise [$w.zinc group current] + variable bw 4 + variable width 60 + variable lightAngle 120 + variable lightAngleRad [deg2Rad $lightAngle] + variable zincSize 500 + + grid [zinc $w.zinc -width $zincSize -height $zincSize -render 1 -font 10x20 \ + -highlightthickness 0 -borderwidth 0 -relief sunken -backcolor lightgray \ + -lightangle $lightAngle] -row 1 -column 0 -columnspan 2 -sticky news + grid columnconfigure $w 0 -weight 1 + grid columnconfigure $w 1 -weight 1 + grid rowconfigure $w 1 -weight 2 + + variable topGroup [$w.zinc add group 1] + + proc polyPoints { ox oy rad n } { + set step [expr 2 * 3.14159 / $n] + for {set i 0} {$i < $n} {incr i} { + set x [expr $ox + ($rad * cos($i * $step))]; + set y [expr $oy + ($rad * sin($i * $step))]; + lappend coords $x $y; + } + lappend coords [lindex $coords 0] [lindex $coords 1] + return $coords + } - set curX $x - set curY $y - set curAngle [expr atan2($y, $x)] - bind $w.zinc "$action %x %y" -} + proc makePoly {x y bw sides color group} { + variable w + variable state + variable allReliefs + variable width + + set relief 2 + + set g [$w.zinc add group $group] + $w.zinc translate $g $x $y + $w.zinc add curve $g [polyPoints 0 0 $width $sides] \ + -relief [lindex $allReliefs $relief] -linewidth $bw \ + -smoothrelief 1 -fillcolor $color -linecolor $color \ + -filled t -tags {subject polygon} + $w.zinc add text $g -anchor center \ + -text [lindex $allReliefs $relief] -tags {subject relief} + $w.zinc add text $g -anchor center -position {0 16} \ + -text $bw -tags {subject bw} + set state($g,sides) $sides + set state($g,relief) $relief + set state($g,bw) $bw + return $g + } -proc motion {x y} { - global w curX curY topGroup + variable poly [makePoly 100 100 $bw 8 lightblue $topGroup] + variable poly [makePoly [expr 100 + 2*($width + 10)] 100 $bw 8 tan $topGroup] + variable poly [makePoly [expr 100 + 4*($width + 10) ] 100 $bw 8 slateblue $topGroup] - foreach {x1 y1 x2 y2} [$w.zinc transform $topGroup \ - [list $x $y $curX $curY]] break - $w.zinc translate [$w.zinc group current] [expr $x1 - $x2] [expr $y1 - $y2] - set curX $x - set curY $y -} + proc lightCenter {radius angle} { + return [list [expr $radius * (1 + 0.95*cos($angle))] \ + [expr $radius * (1 - 0.95*sin($angle))]] + } -proc lightMotion {x y} { - global w zincSize topGroup + # + # Place the light at lightAngle on the circle + $w.zinc add arc 1 {-5 -5 5 5} -filled 1 -fillcolor yellow \ + -tags light -priority 10 + eval "$w.zinc translate light [lightCenter [expr $zincSize/2] $lightAngleRad]" + + # + # Controls. + # + $w.zinc bind subject "::reliefDemo::press motion %x %y" + $w.zinc bind subject ::reliefDemo::release + $w.zinc bind subject "::reliefDemo::press zoom %x %y" + $w.zinc bind subject ::reliefDemo::release + $w.zinc bind subject "::reliefDemo::press mouseRotate %x %y" + $w.zinc bind subject ::reliefDemo::release + + $w.zinc bind polygon "::reliefDemo::incrPolySides 1" + $w.zinc bind polygon "::reliefDemo::incrPolySides -1" + + $w.zinc bind subject "::reliefDemo::cycleRelief 1" + $w.zinc bind subject "::reliefDemo::cycleRelief -1" + + $w.zinc bind subject "::reliefDemo::incrBW 1" + $w.zinc bind subject "::reliefDemo::incrBW -1" + + $w.zinc bind light "::reliefDemo::press lightMotion %x %y" + $w.zinc bind light ::reliefDemo::release + + variable curX 0 + variable curY 0 + variable curAngle 0 + + proc press {action x y} { + variable w + variable curAngle + variable curX + variable curY + + $w.zinc raise [$w.zinc group current] + + set curX $x + set curY $y + set curAngle [expr atan2($y, $x)] + bind $w.zinc "::reliefDemo::$action %x %y" + } - set radius [expr $zincSize/2] - if { $x < 0 } { - set x 0 - } elseif { $x > $zincSize } { - set x $zincSize + proc motion {x y} { + variable w + variable curX + variable curY + variable topGroup + + foreach {x1 y1 x2 y2} [$w.zinc transform $topGroup \ + [list $x $y $curX $curY]] break + $w.zinc translate [$w.zinc group current] [expr $x1 - $x2] [expr $y1 - $y2] + set curX $x + set curY $y } + + proc lightMotion {x y} { + variable w + variable zincSize + variable topGroup + + set radius [expr $zincSize/2] + if { $x < 0 } { + set x 0 + } elseif { $x > $zincSize } { + set x $zincSize + } - set angle [expr acos(double($x-$radius)/$radius)] - if { $y > $radius } { - set angle [expr - $angle] + set angle [expr acos(double($x-$radius)/$radius)] + if { $y > $radius } { + set angle [expr - $angle] + } + $w.zinc treset light + eval "$w.zinc translate light [lightCenter [expr $zincSize/2] $angle]" + $w.zinc configure -lightangle [rad2Deg $angle] } - $w.zinc treset light - eval "$w.zinc translate light [lightCenter [expr $zincSize/2] $angle]" - $w.zinc configure -lightangle [rad2Deg $angle] -} - -proc zoom {x y} { - global w curX curY - if {$x > $curX} { - set maxX $x - } else { - set maxX $curX - } - if {$y > $curY} { - set maxY $y - } else { - set maxY $curY - } - if {($maxX == 0) || ($maxY == 0)} { - return; + proc zoom {x y} { + variable w + variable curX + variable curY + + if {$x > $curX} { + set maxX $x + } else { + set maxX $curX + } + if {$y > $curY} { + set maxY $y + } else { + set maxY $curY + } + if {($maxX == 0) || ($maxY == 0)} { + return; + } + set sx [expr 1.0 + (double($x - $curX) / $maxX)] + set sy [expr 1.0 + (double($y - $curY) / $maxY)] + $w.zinc scale current $sx $sx + + set curX $x + set curY $y } - set sx [expr 1.0 + (double($x - $curX) / $maxX)] - set sy [expr 1.0 + (double($y - $curY) / $maxY)] - $w.zinc scale current $sx $sx - set curX $x - set curY $y -} - -proc mouseRotate {x y} { - global w curAngle - - set lAngle [expr atan2($y, $x)] - $w.zinc rotate current [expr $lAngle - $curAngle] - set curAngle $lAngle -} - -proc release {} { - global w + proc mouseRotate {x y} { + variable w + variable curAngle - bind $w.zinc {} -} + set lAngle [expr atan2($y, $x)] + $w.zinc rotate current [expr $lAngle - $curAngle] + set curAngle $lAngle + } -proc incrPolySides {incr} { - global w state width + proc release {} { + variable w - set g [$w.zinc group current] - incr state($g,sides) $incr - if { $state($g,sides) < 3 } { - set state($g,sides) 3 + bind $w.zinc {} } - set points [polyPoints 0 0 $width $state($g,sides)] - $w.zinc coords $g.polygon $points -} + proc incrPolySides {incr} { + variable w + variable state + variable width -proc cycleRelief {incr} { - global w state allReliefs + set g [$w.zinc group current] + incr state($g,sides) $incr + if { $state($g,sides) < 3 } { + set state($g,sides) 3 + } - set g [$w.zinc group current] - incr state($g,relief) $incr - if { $state($g,relief) < 0 } { - set state($g,relief) [expr [llength $allReliefs] - 1] - } elseif { $state($g,relief) >= [llength $allReliefs] } { - set state($g,relief) 0 + set points [polyPoints 0 0 $width $state($g,sides)] + $w.zinc coords $g.polygon $points } - set rlf [lindex $allReliefs $state($g,relief)] - $w.zinc itemconfigure $g.polygon -relief $rlf - $w.zinc itemconfigure $g.relief -text $rlf -} -proc incrBW {incr} { - global w state + proc cycleRelief {incr} { + variable w + variable state + variable allReliefs + + set g [$w.zinc group current] + incr state($g,relief) $incr + if { $state($g,relief) < 0 } { + set state($g,relief) [expr [llength $allReliefs] - 1] + } elseif { $state($g,relief) >= [llength $allReliefs] } { + set state($g,relief) 0 + } + set rlf [lindex $allReliefs $state($g,relief)] + $w.zinc itemconfigure $g.polygon -relief $rlf + $w.zinc itemconfigure $g.relief -text $rlf + } - set g [$w.zinc group current] - incr state($g,bw) $incr - if { $state($g,bw) < 0 } { - set state($g,bw) 0 + proc incrBW {incr} { + variable w + variable state + + set g [$w.zinc group current] + incr state($g,bw) $incr + if { $state($g,bw) < 0 } { + set state($g,bw) 0 + } + $w.zinc itemconfigure $g.polygon -linewidth $state($g,bw) + $w.zinc itemconfigure $g.bw -text $state($g,bw) } - $w.zinc itemconfigure $g.polygon -linewidth $state($g,bw) - $w.zinc itemconfigure $g.bw -text $state($g,bw) } diff --git a/demos/tiger.tcl b/demos/tiger.tcl index 516d5c6..3baef6e 100644 --- a/demos/tiger.tcl +++ b/demos/tiger.tcl @@ -19,7 +19,7 @@ namespace eval tigerDemo { wm title $w "Zinc tiger (Generated from SVG) Demonstration" wm iconname $w tiger - variable defaultfont [font create -family Helvetica -size 10 -weight bold] + variable defaultfont [font create -family Helvetica -size 16 -weight normal] grid [button $w.dismiss -text Dismiss -command "destroy $w"] -row 2 -column 0 -pady 10 grid [button $w.code -text "See Code" -command "showCode $w"] -row 2 -column 1 -pady 10 @@ -28,7 +28,7 @@ namespace eval tigerDemo { ########################################### # Zinc ########################################## - grid [zinc $w.zinc -width 600 -height 600 -font 9x15 -borderwidth 0 -backcolor grey90 \ + grid [zinc $w.zinc -width 600 -height 600 -font $defaultfont -borderwidth 0 -backcolor grey90 \ -render 1] -row 0 -column 0 -columnspan 2 -sticky news # -reshape 1 -fullreshape 1 grid columnconfigure $w 0 -weight 1 diff --git a/demos/tkZincLogo.tcl b/demos/tkZincLogo.tcl index 2af91d4..5317f36 100644 --- a/demos/tkZincLogo.tcl +++ b/demos/tkZincLogo.tcl @@ -8,151 +8,161 @@ if {![info exists zincDemo]} { error "This script should be run from the zinc-widget demo." } -# -# We need the zincLogo support -package require zincLogo - - -set w .tkZincLogo -catch {destroy $w} -toplevel $w -wm title $w "Zinc logo Demonstration" -wm iconname $w tkZincLogo - -set defaultfont [font create -family Helvetica -size 10 -weight bold] - -frame $w.buttons -pack $w.buttons -side bottom -fill x -pady 2m -button $w.buttons.dismiss -text Dismiss -command "destroy $w" -button $w.buttons.code -text "See Code" -command "showCode $w" -pack $w.buttons.dismiss $w.buttons.code -side left -expand 1 - - - -########################################### -# Text zone -####################### -#################### - -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! - You can transform this logo with your mouse: - Drag-Button 1 for moving the logo, - Drag-Button 2 for zooming the logo, - Drag-Button 3 for rotating the logo, - Shift-Drag-Button 1 for modifying the logo transparency, - Shift-Drag-Button 2 for modifying the logo gradient.} - - -########################################### -# Zinc -########################################## -zinc $w.zinc -width 350 -height 250 -render 1 -font 10x20 \ - -borderwidth 3 -relief sunken -pack $w.zinc - -set topGroup [$w.zinc add group 1] - -set logo [zincLogo::create $w.zinc $topGroup 800 40 70 0.6 0.6] - -# -# Controls for the window transform. -# -bind $w.zinc "press motion %x %y" -bind $w.zinc release -bind $w.zinc "press zoom %x %y" -bind $w.zinc release -bind $w.zinc "press mouseRotate %x %y" -bind $w.zinc release - -# -# Controls for alpha and gradient -# -bind $w.zinc "press modifyAlpha %x %y" -bind $w.zinc release -bind $w.zinc "press modifyGradient %x %y" -bind $w.zinc release - - -set curX 0 -set curY 0 -set curAngle 0 - -proc press {action x y} { - global w curAngle curX curY - - set curX $x - set curY $y - set curAngle [expr atan2($y, $x)] - bind $w.zinc "$action %x %y" -} - -proc motion {x y} { - global w topGroup curX curY - - foreach {x1 y1 x2 y2} [$w.zinc transform $topGroup \ - [list $x $y $curX $curY]] break - $w.zinc translate $topGroup [expr $x1 - $x2] [expr $y1 - $y2] - set curX $x - set curY $y -} - -proc zoom {x y} { - global w topGroup curX curY - - if {$x > $curX} { - set maxX $x - } else { - set maxX $curX - } - if {$y > $curY} { - set maxY $y - } else { - set maxY $curY +namespace eval tkZincLogo { + # + # We need the zincLogo support + package require zincLogo + + + variable w .tkZincLogo + catch {destroy $w} + toplevel $w + wm title $w "Zinc logo Demonstration" + wm iconname $w tkZincLogo + + grid [button $w.dismiss -text Dismiss -command "destroy $w"] -row 2 -column 0 -pady 10 + grid [button $w.code -text "See Code" -command "showCode $w"] -row 2 -column 1 -pady 10 + + + ########################################### + # Text zone + ####################### + #################### + + grid [text $w.text -relief sunken -borderwidth 2 -height 7] \ + -row 0 -column 0 -columnspan 2 -sticky ew + + $w.text insert end {This tkZinc logo should used openGL for a correct rendering! + You can transform this logo with your mouse: + Drag-Button 1 for moving the logo, + Drag-Button 2 for zooming the logo, + Drag-Button 3 for rotating the logo, + Shift-Drag-Button 1 for modifying the logo transparency, + Shift-Drag-Button 2 for modifying the logo gradient.} + + + ########################################### + # Zinc + ########################################## + grid [ zinc $w.zinc -width 350 -height 250 -render 1 \ + -borderwidth 3 -relief sunken] -row 1 -column 0 -columnspan 2 -sticky news + grid columnconfigure $w 0 -weight 1 + grid columnconfigure $w 1 -weight 1 + grid rowconfigure $w 1 -weight 2 + + variable topGroup [$w.zinc add group 1] + + variable logo [zincLogo::create $w.zinc $topGroup 800 40 70 0.6 0.6] + + # + # Controls for the window transform. + # + bind $w.zinc "::tkZincLogo::press motion %x %y" + bind $w.zinc ::tkZincLogo::release + bind $w.zinc "::tkZincLogo::press zoom %x %y" + bind $w.zinc ::tkZincLogo::release + bind $w.zinc "::tkZincLogo::press mouseRotate %x %y" + bind $w.zinc ::tkZincLogo::release + + # + # Controls for alpha and gradient + # + bind $w.zinc "::tkZincLogo::press modifyAlpha %x %y" + bind $w.zinc ::tkZincLogo::release + bind $w.zinc "::tkZincLogo::press modifyGradient %x %y" + bind $w.zinc ::tkZincLogo::release + + + variable curX 0 + variable curY 0 + variable curAngle 0 + + proc press {action x y} { + variable w + variable curAngle + variable curX + variable curY + + set curX $x + set curY $y + set curAngle [expr atan2($y, $x)] + bind $w.zinc "::tkZincLogo::$action %x %y" } - if {($maxX == 0) || ($maxY == 0)} { - return; + + proc motion {x y} { + variable w + variable topGroup + variable curX + variable curY + + foreach {x1 y1 x2 y2} [$w.zinc transform $topGroup \ + [list $x $y $curX $curY]] break + $w.zinc translate $topGroup [expr $x1 - $x2] [expr $y1 - $y2] + set curX $x + set curY $y } - set sx [expr 1.0 + (double($x - $curX) / $maxX)] - set sy [expr 1.0 + (double($y - $curY) / $maxY)] - $w.zinc scale $topGroup $sx $sx - set curX $x - set curY $y -} + proc zoom {x y} { + variable w + variable topGroup + variable curX + variable curY + + if {$x > $curX} { + set maxX $x + } else { + set maxX $curX + } + if {$y > $curY} { + set maxY $y + } else { + set maxY $curY + } + if {($maxX == 0) || ($maxY == 0)} { + return; + } + set sx [expr 1.0 + (double($x - $curX) / $maxX)] + set sy [expr 1.0 + (double($y - $curY) / $maxY)] + $w.zinc scale $topGroup $sx $sx + + set curX $x + set curY $y + } -proc mouseRotate {x y} { - global w curAngle logo + proc mouseRotate {x y} { + variable w + variable curAngle + variable logo - set lAngle [expr atan2($y, $x)] - $w.zinc rotate $logo [expr $lAngle - $curAngle] - set curAngle $lAngle -} + set lAngle [expr atan2($y, $x)] + $w.zinc rotate $logo [expr $lAngle - $curAngle] + set curAngle $lAngle + } -proc release {} { - global w + proc release {} { + variable w - bind $w.zinc {} -} + bind $w.zinc {} + } -proc modifyAlpha {x y} { - global w topGroup + proc modifyAlpha {x y} { + variable w + variable topGroup - set xRate [expr double($x) / [$w.zinc cget -width]] - set xRate [expr ($xRate < 0) ? 0 : ($xRate > 1) ? 1 : $xRate] - set alpha [expr int($xRate * 100)] + set xRate [expr double($x) / [$w.zinc cget -width]] + set xRate [expr ($xRate < 0) ? 0 : ($xRate > 1) ? 1 : $xRate] + set alpha [expr int($xRate * 100)] - $w.zinc itemconfigure $topGroup -alpha $alpha -} + $w.zinc itemconfigure $topGroup -alpha $alpha + } -proc modifyGradient {x y} { - global w + proc modifyGradient {x y} { + variable w - set yRate [expr double($y) / [$w.zinc cget -height]] - set yRate [expr ($yRate < 0) ? 0 : ($yRate > 1) ? 1 : $yRate] - set gradPercent [expr int($yRate * 100)] - - $w.zinc itemconfigure letters -fillcolor "=axial 270|#ffffff;100 0 28|#66848c;100 $gradPercent|#7192aa;100 100" + set yRate [expr double($y) / [$w.zinc cget -height]] + set yRate [expr ($yRate < 0) ? 0 : ($yRate > 1) ? 1 : $yRate] + set gradPercent [expr int($yRate * 100)] + + $w.zinc itemconfigure letters -fillcolor "=axial 270|#ffffff;100 0 28|#66848c;100 $gradPercent|#7192aa;100 100" + } } diff --git a/demos/transforms.tcl b/demos/transforms.tcl index 9588044..4eb5e16 100644 --- a/demos/transforms.tcl +++ b/demos/transforms.tcl @@ -18,7 +18,7 @@ namespace eval transforms { wm title $w "Zinc Transformation Demonstration" wm iconname $w Transformation - variable defaultfont [font create -family Helvetica -size 10 -weight bold] + variable defaultfont [font create -family Helvetica -size 14 -weight normal] grid [button $w.dismiss -text Dismiss -command "destroy $w"] -row 3 -column 0 -pady 10 grid [button $w.code -text "See Code" -command "showCode $w"] -row 3 -column 1 -pady 10 @@ -53,7 +53,7 @@ namespace eval transforms { variable zincHeight 500 grid [zinc $w.zinc -width $zincWidth -height $zincHeight \ - -font 10x20 -borderwidth 3 -relief sunken -takefocus 1 -render 0] \ + -font $defaultfont -borderwidth 3 -relief sunken -takefocus 1 -render 0] \ -row 1 -column 0 -columnspan 2 -sticky news grid columnconfigure $w 0 -weight 1 grid columnconfigure $w 1 -weight 1 diff --git a/demos/triangles.tcl b/demos/triangles.tcl index d106bf1..7326f32 100644 --- a/demos/triangles.tcl +++ b/demos/triangles.tcl @@ -5,42 +5,44 @@ if {![info exists zincDemo]} { error "This script should be run from the zinc-widget demo." } -set w .triangles -catch {destroy $w} -toplevel $w -wm title $w "Zinc Triangles Demonstration" -wm iconname $w Triangles +namespace eval trianglesDemo { + variable w .triangles + catch {destroy $w} + toplevel $w + wm title $w "Zinc Triangles Demonstration" + wm iconname $w Triangles -frame $w.buttons -pack $w.buttons -side bottom -fill x -pady 2m -button $w.buttons.dismiss -text Dismiss -command "destroy $w" -button $w.buttons.code -text "See Code" -command "showCode $w" -pack $w.buttons.dismiss $w.buttons.code -side left -expand 1 + grid [button $w.dismiss -text Dismiss -command "destroy $w"] -row 2 -column 0 -pady 10 + grid [button $w.code -text "See Code" -command "showCode $w"] -row 2 -column 1 -pady 10 + variable defaultfont [font create -family Helvetica -size 16 -weight normal] -set defaultfont [font create -family Helvetica -size 10 -weight bold] + grid [zinc $w.zinc -width 700 -height 300 -font $defaultfont -render 1 -borderwidth 3 -relief sunken] \ + -row 1 -column 0 -columnspan 2 -sticky news + grid columnconfigure $w 0 -weight 1 + grid columnconfigure $w 1 -weight 1 + grid rowconfigure $w 1 -weight 2 + -zinc $w.zinc -width 700 -height 300 -font 10x20 -render 1 -borderwidth 3 -relief sunken -pack $w.zinc + # 6 equilateral triangles around a point + $w.zinc add text 1 -position {40 10} -text "Triangles item without transparency" -# 6 equilateral triangles around a point -$w.zinc add text 1 -position {5 10} -text "Triangles item without transparency" + variable x0 200 + variable y0 150 + variable coords [list "$x0 $y0"] + for {set i 0} {$i<=6} {incr i} { + set angle [expr $i * 6.28/6] + lappend coords "[expr $x0 + 100 * cos($angle)] [expr $y0 - 100 * sin ($angle)]" + } -set x0 200 -set y0 150 -set coords [list "$x0 $y0"] -for {set i 0} {$i<=6} {incr i} { - set angle [expr $i * 6.28/6] - lappend coords "[expr $x0 + 100 * cos($angle)] [expr $y0 - 100 * sin ($angle)]" -} - -set tr1 [$w.zinc add triangles 1 $coords -fan 1 -colors {white yellow red magenta blue cyan green yellow} -visible 1] + set tr1 [$w.zinc add triangles 1 $coords -fan 1 -colors {white yellow red magenta blue cyan green yellow} -visible 1] -$w.zinc add text 1 -position {370 10} -text "Triangles item with transparency" + $w.zinc add text 1 -position {370 10} -text "Triangles item with transparency" -# using the clone method to make a copy and then modify the clone"colors -set tr2 [$w.zinc clone $tr1] -$w.zinc translate $tr2 300 0 -$w.zinc itemconfigure $tr2 -colors {white;50 yellow;50 red;50 magenta;50 blue;50 cyan;50 green;50 yellow;50} + # using the clone method to make a copy and then modify the clone"colors + set tr2 [$w.zinc clone $tr1] + $w.zinc translate $tr2 300 0 + $w.zinc itemconfigure $tr2 -colors {white;50 yellow;50 red;50 magenta;50 blue;50 cyan;50 green;50 yellow;50} +} diff --git a/demos/windowContours.tcl b/demos/windowContours.tcl index 19aacb1..7b6c263 100644 --- a/demos/windowContours.tcl +++ b/demos/windowContours.tcl @@ -12,7 +12,7 @@ namespace eval windowContours { wm title $w "Zinc Contours Demonstration" wm iconname $w Contours - variable defaultfont [font create -family Helvetica -size 10 -weight bold] + variable defaultfont [font create -family Helvetica -size 20 -weight normal] grid [button $w.dismiss -text Dismiss -command "destroy $w"] -row 2 -column 0 -pady 10 grid [button $w.code -text "See Code" -command "showCode $w"] -row 2 -column 1 -pady 10 @@ -29,9 +29,12 @@ namespace eval windowContours { # Text in background - variable backtext [$w.zinc add text 1 -position {50 200} -text "This text appears\nthrough holes of curves" -font "-adobe-helvetica-bold-o-normal--34-240-100-100-p-182-iso8859-1"] + variable backtext [$w.zinc add text 1 -position {50 200} \ + -text "This text appears\nthrough holes of curves" \ + -font "-adobe-helvetica-bold-o-normal--34-240-100-100-p-182-iso8859-1"] - variable window [$w.zinc add curve 1 {100 100 300 100 300 400 100 400} -closed 1 -visible 1 -filled 1 -fillcolor grey66] + variable window [$w.zinc add curve 1 {100 100 300 100 300 400 100 400} -closed 1 \ + -visible 1 -filled 1 -fillcolor grey66] variable aGlass [$w.zinc add rectangle 1 {120 120 190 240}] -- cgit v1.1