aboutsummaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
Diffstat (limited to 'demos')
-rw-r--r--demos/contours.tcl28
1 files changed, 15 insertions, 13 deletions
diff --git a/demos/contours.tcl b/demos/contours.tcl
index efa13de..b9ead37 100644
--- a/demos/contours.tcl
+++ b/demos/contours.tcl
@@ -34,37 +34,38 @@ The following operations are possible:
# Creating the zinc widget
zinc $w.zinc -width 600 -height 500 -font 10x20 -borderwidth 3 -relief sunken
pack $w.zinc
-
+set top 1
# Creation of 2 items NOT visible, but used for creating visible
# curves[1-5] with more than one contours.
# The center of these 2 items is 200,100
-set curve0 [$w.zinc add curve 1 { {300 0} {400 100 c} {300 200} {200 300 c} {100 200} {0 100 c} {100 0} } -closed 1 -visible 0 -filled 1]
+set curve0 [$w.zinc add curve $top {
+ {300 0} {400 100 c} {300 200} {200 300 c} {100 200} {0 100 c} {100 0}
+} -closed 1 -visible 0 -filled 1]
set cercle100 [$w.zinc add arc 1 {130 30 280 180} -visible 0]
# cloning curve0 as curve1 and moving it
set curve1 [$w.zinc clone $curve0 -visible 1 -fillcolor firebrick1]
-# adding a ifference' contour to the curve1
-$w.zinc contour $curve1 add +1 $cercle100
+# adding a 'difference' contour to the curve1
+$w.zinc contour $curve1 add 1 $cercle100
# cloning curve0 as curve2 and moving it
# creating a curve without contour to control contour clockwise/counterclockwise
-set curve2 [$w.zinc add curve 1 {} -closed 1 -filled 1 -visible 1 -fillcolor lightblue2 -fillrule positive]
-$w.zinc contour $curve2 add -1 $curve0
-## why must the flag be -1 and not -1 !?
-
-# adding the left ear of mickey mouse!
+set curve2 [$w.zinc add curve $top {} -closed 1 -filled 1 \
+ -fillcolor lightblue2 -fillrule positive]
+$w.zinc contour $curve2 add +1 $curve0
$w.zinc translate $curve2 100 90
-# adding the right ear of mickey mouse!
+# adding the left ear of mickey mouse!
$w.zinc contour $curve2 add +1 $cercle100
$w.zinc translate $curve2 -200 0
-# adding an 'intersection' contour to the curve2
+# adding the right ear of mickey mouse!
$w.zinc contour $curve2 add +1 $cercle100
+
# ... translate to make it more visible
$w.zinc translate $curve2 320 20
@@ -81,7 +82,8 @@ $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]
+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
@@ -91,7 +93,7 @@ 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]" \
+set handle [$w.zinc add rectangle $top "[expr $x-5] [expr $y-5] [expr $x+5] [expr $y+5]" \
-fillcolor black -filled 1 -tags {grouped}]