aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormertz2003-01-17 13:31:47 +0000
committermertz2003-01-17 13:31:47 +0000
commit57f589c6f81df8176531e6ed143566f5ea3c3dbe (patch)
tree4ddad2bb137a142c5830d9bd895514aca28a038a
parent02b2cc44046d8fd4af4ab2c81de9a8db27d67e8c (diff)
downloadtkzinc-57f589c6f81df8176531e6ed143566f5ea3c3dbe.zip
tkzinc-57f589c6f81df8176531e6ed143566f5ea3c3dbe.tar.gz
tkzinc-57f589c6f81df8176531e6ed143566f5ea3c3dbe.tar.bz2
tkzinc-57f589c6f81df8176531e6ed143566f5ea3c3dbe.tar.xz
passage � la m�thode contour de zinc 3.2.6g.
-rw-r--r--Perl/demos/Tk/demos/zinc_lib/clipping.pl2
-rw-r--r--Perl/demos/Tk/demos/zinc_lib/contours.pl43
-rw-r--r--Perl/demos/Tk/demos/zinc_lib/counter.pl2
-rw-r--r--Perl/demos/Tk/demos/zinc_lib/window-contours.pl8
4 files changed, 31 insertions, 24 deletions
diff --git a/Perl/demos/Tk/demos/zinc_lib/clipping.pl b/Perl/demos/Tk/demos/zinc_lib/clipping.pl
index ac9a024..6e167d0 100644
--- a/Perl/demos/Tk/demos/zinc_lib/clipping.pl
+++ b/Perl/demos/Tk/demos/zinc_lib/clipping.pl
@@ -40,7 +40,7 @@ my $clipping_item = $zinc->add('curve', $clipped_group,
-fillcolor => "tan2",
-linewidth => 0,
-filled => $display_clipping_item_background);
-$zinc->contour($clipping_item, "addhole", [200,200, 500,200, 500,250, 200,250]);
+$zinc->contour($clipping_item, "add", +1, [200,200, 500,200, 500,250, 200,250]);
############### creating the tan_group objects ################
# the tan_group is atomic, that is is makes all children as a single object
diff --git a/Perl/demos/Tk/demos/zinc_lib/contours.pl b/Perl/demos/Tk/demos/zinc_lib/contours.pl
index 5d4a4ed..e9521e8 100644
--- a/Perl/demos/Tk/demos/zinc_lib/contours.pl
+++ b/Perl/demos/Tk/demos/zinc_lib/contours.pl
@@ -21,7 +21,7 @@ $text->insert('0.0',
- the firebrick curve1 has been holed using a addhole with a circle,
- the lightblue curve2 has been "mickey-moused" by adding two circles,
- the yellow curve3 is the union with a disjoint circle,
- - the grey curve4 is added to and holed with with many circle.
+ - the grey curve4 is combined with 7 circles, with \'positive\' -fillrule.
The following operations are possible:
- "Mouse Button 1" for dragging objects.
- "Mouse Button 1" for dragging the black handle and
@@ -38,7 +38,7 @@ my $zinc = $mw->Zinc(-width => 600, -height => 500,
# 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
-my $curve0 = $zinc->add('curve', 1, [0,100 , 100,0, 300,0 , 400,100, 300,200, 100,200],
+my $curve0 = $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,
);
my $cercle100 = $zinc->add('arc', 1, [130,30, 280,180],
@@ -48,18 +48,22 @@ my $cercle100 = $zinc->add('arc', 1, [130,30, 280,180],
# cloning curve0 as curve1 and moving it
my $curve1 = $zinc->clone($curve0, -visible => 1, -fillcolor => "firebrick1");
# adding a 'difference' contour to the curve1
-$zinc->contour($curve1, 'addhole', $cercle100);
+$zinc->contour($curve1, 'add', +1, $cercle100);
# cloning curve0 as curve2 and moving it
-my $curve2 = $zinc->clone($curve0, -visible => 1, -fillcolor => "lightblue2");
+# creating a curve without contour to control contour clockwise/counterclockwise
+my $curve2 = $zinc->add('curve', 1, [], -closed => 1, -filled => 1,
+ -visible => 1, -fillcolor => "lightblue2", -fillrule => 'positive');
+$zinc->contour($curve2, 'add', -1, $curve0); ## why must the flag be -1 and not -1 !?
+# adding the left ear of mickey mouse!
$zinc->translate($curve2,100,90);
-# adding an 'intersection' contour to the curve2
-$zinc->contour($curve2, 'add', $cercle100);
+# adding the right ear of mickey mouse!
+$zinc->contour($curve2, 'add', +1, $cercle100);
$zinc->translate($curve2,-200,0);
# adding an 'intersection' contour to the curve2
-$zinc->contour($curve2, 'add', $cercle100);
+$zinc->contour($curve2, 'add', +1, $cercle100);
# ... translate to make it more visible
$zinc->translate($curve2, 320,20);
@@ -69,7 +73,7 @@ $zinc->translate($curve2, 320,20);
my $curve3 = $zinc->clone($curve0, -visible => 1, -fillcolor => "yellow3");
$zinc->translate($curve3,0,290);
# adding an 'union' contour to the curve3
-$zinc->contour($curve3, 'add', $cercle100);
+$zinc->contour($curve3, 'add', +1, $cercle100);
# ... translate to make it more visible
$zinc->translate($curve3, -130,00);
@@ -79,31 +83,34 @@ $zinc->translate($curve3, -130,00);
# cloning curve0 as curve4 and moving it slightly
my $curve4 = $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
);
-my ($x,$y) = $zinc->coords($curve4,0,1);
+
+my $index = 2; ## index of the vertex associated to the handle
+my ($x,$y) = $zinc->coords($curve4,0,$index);
my $handle = $zinc->add('rectangle', 1, [$x-5,$y-5,$x+5,$y+5],
-fillcolor => 'black', -filled => 1,
-tags => ["grouped"],
);
# adding a 'difference' contour to the curve4
-$zinc->contour($curve4, 'addhole', $cercle100);
+$zinc->contour($curve4, 'add', +1, $cercle100);
$zinc->translate('grouped',110,0);
-$zinc->contour($curve4, 'addhole', $cercle100);
+$zinc->contour($curve4, 'add', +1, $cercle100);
$zinc->translate('grouped',-220,0);
-$zinc->contour($curve4, 'add', $cercle100);
+$zinc->contour($curve4, 'add', +1, $cercle100);
$zinc->translate('grouped',110,80);
-$zinc->contour($curve4, 'add', $cercle100);
+$zinc->contour($curve4, 'add', -1, $cercle100);
$zinc->translate('grouped',0,-160);
-$zinc->contour($curve4, 'add', $cercle100);
+$zinc->contour($curve4, 'add', +1, $cercle100);
$zinc->translate('grouped',200,80);
-$zinc->contour($curve4, 'addhole', $cercle100);
+$zinc->contour($curve4, 'add', +1, $cercle100);
$zinc->translate('grouped',-350,0);
-$zinc->contour($curve4, 'add', $cercle100);
+$zinc->contour($curve4, 'add', +1, $cercle100);
$zinc->translate('grouped',350,250);
#$zinc->lower('grouped');
@@ -174,8 +181,8 @@ sub moveHandle {
$zinc->translate($handle, $x-$x_orig, $y-$y_orig);
- my ($vertxX,$vertxY) = $zinc->coords($curve4,0,1);
- $zinc->coords($curve4,0,1, [$vertxX+($x-$x_orig), $vertxY+($y-$y_orig)]);
+ my ($vertxX,$vertxY) = $zinc->coords($curve4,0,$index);
+ $zinc->coords($curve4,0,$index, [$vertxX+($x-$x_orig), $vertxY+($y-$y_orig)]);
$x_orig = $x;
$y_orig = $y;
}
diff --git a/Perl/demos/Tk/demos/zinc_lib/counter.pl b/Perl/demos/Tk/demos/zinc_lib/counter.pl
index 45b5208..5df227b 100644
--- a/Perl/demos/Tk/demos/zinc_lib/counter.pl
+++ b/Perl/demos/Tk/demos/zinc_lib/counter.pl
@@ -228,7 +228,7 @@ my $clipping_item2 = $zinc->add('curve', $clipped_group2,
-linewidth=>0,
);
-$zinc->contour($clipping_item2,"addhole",[$x2,$y2,$x3,$y2,$x3,$y3,$x2,$y3,$x2,$y2]);
+$zinc->contour($clipping_item2,"add",0,[$x2,$y2,$x3,$y2,$x3,$y3,$x2,$y3,$x2,$y2]);
#--------------------------------
# Clipped items
diff --git a/Perl/demos/Tk/demos/zinc_lib/window-contours.pl b/Perl/demos/Tk/demos/zinc_lib/window-contours.pl
index 9199f20..c51782c 100644
--- a/Perl/demos/Tk/demos/zinc_lib/window-contours.pl
+++ b/Perl/demos/Tk/demos/zinc_lib/window-contours.pl
@@ -41,16 +41,16 @@ my $window = $zinc->add('curve', 1, [100,100 , 300,100, 300,400 , 100,400 ],
);
my $aGlass= $zinc->add('rectangle', 1, [120,120 , 190,240]);
-$zinc->contour($window, 'addhole', $aGlass);
+$zinc->contour($window, 'add', +1, $aGlass);
$zinc->translate($aGlass, 90,0);
-$zinc->contour($window, 'addhole', $aGlass);
+$zinc->contour($window, 'add', +1, $aGlass);
$zinc->translate($aGlass, 0,140);
-$zinc->contour($window, 'addhole', $aGlass);
+$zinc->contour($window, 'add', +1, $aGlass);
$zinc->translate($aGlass, -90,0);
-$zinc->contour($window, 'addhole', $aGlass);
+$zinc->contour($window, 'add', +1, $aGlass);
# deleting $aGlass which is no more usefull
$zinc->remove($aGlass);