From fc0a7b5b93c7f751c266278264e3f0d14838e6ce Mon Sep 17 00:00:00 2001 From: lecoanet Date: Tue, 5 Nov 2002 09:13:59 +0000 Subject: *** empty log message *** --- sandbox/testshape.pl | 79 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 71 insertions(+), 8 deletions(-) (limited to 'sandbox') diff --git a/sandbox/testshape.pl b/sandbox/testshape.pl index 9d6a76e..a55de42 100644 --- a/sandbox/testshape.pl +++ b/sandbox/testshape.pl @@ -9,21 +9,84 @@ $mw = MainWindow->new(); $top = 1; $zinc = $mw->Zinc(-render => 1, -borderwidth => 0, - -fullreshape => 0, +# -fullreshape => 0, -relief => 'sunken'); $zinc->pack(-expand => 1, -fill => 'both'); $zinc->configure(-width => 500, -height => 500); -$arc = $zinc->add('arc', $top, [50, 50, 200, 100], - -visible => 0); -$cv = $zinc->add('curve', $top, [50, 50, 100, 150, 270, 70, - 220, 0, 200, 20, 180, -100, - 140, 40, 70, -100], - -visible => 0); -$zinc->itemconfigure($top, -clip => $arc); +# $arc = $zinc->add('arc', $top, [50, 50, 200, 100], +# -visible => 0); +#$zinc->itemconfigure($top, -clip => $arc); $view = $zinc->add('group', $top, -tags => "controls"); +# $cv = $zinc->add('curve', $view, [50, 50, 100, 150, 270, 70, +# 220, 0, 200, 20, 180, 100, +# 140, 40, 70, 100], +# -visible => 1, +# -closed => 1, +# -filled => 1); + +$arc = $zinc->add('arc', $view, [90,0, 160,50], + -visible => 0, + -linewidth => 0, + -filled => 1, + -fillcolor => 'brown'); +# $rect = $zinc->add('rectangle', $view, [200,230, 220,250], +# -visible => 1, +# -linewidth => 2, +# -relief => 'sunken', +# -filled => 1, +# -linecolor => 'white', +# -fillcolor => 'tan'); +$cv2 = $zinc->add('curve', $view, [], + -visible => 1, + -linewidth => 2, + -linecolor => 'white', + -fillcolor => 'tan', + -relief => 'sunken', + -closed => 1, + -filled => 1); +$text = $zinc->add('text', $view, + -visible => 1, + -text => 'Un Texte ICI', + -position => [200, 100], + -color => '#008000'); +$zinc->contour($cv2, 'add', [[20, 20], [20, 100, 'c'], [120, 100], [120, 20]]); +$zinc->contour($cv2, 'addhole', [40, 40, 80, 40, 80, 80, 40, 80]); +$zinc->contour($cv2, 'add', [60, 50, 60, 60, 70, 60, 70, 50]); +$zinc->contour($cv2, 'addhole', [90, 70, 150, 70, 150, 150, 90, 150]); +$zinc->contour($cv2, 'add', [200, 200, 200, 220, 220, 220, 220, 200]); +$zinc->contour($cv2, 'addhole', [100, 10, 180, 10, 180, 60, 100, 60]); + +$zinc->contour($cv2, 'add', $arc); +$zinc->contour($cv2, 'add', $text); + +# $rect2 = $zinc->add('rectangle', $view, [40,81, 80,130], +# -visible => 1, +# -linewidth => 1, +# -relief => 'sunken', +# -filled => 1, +# -linecolor => 'white', +# -fillcolor => 'tan'); new Controls($zinc); +$zinc->Tk::bind('', sub {print "hop\n", $zinc->contour($cv2, 'remove', 1);}); +$zinc->Tk::bind('', sub {my ($x,$y,$c) = $zinc->coords($cv2, 0, 1); + if ($c eq 'c') { + $zinc->coords($cv2, 0, 1, [[20, 100]]); + } + else { + $zinc->coords($cv2, 0, 1, [[20, 100, 'c']]); + }}); +$zinc->Tk::bind('<1>', sub { + my $ev = $zinc->XEvent(); + my $it = $zinc->find('closest', $ev->x, $ev->y); + my @t = $zinc->vertexat($it, $ev->x, $ev->y); + print "Closest: $it\n"; + print "VertexAt: ", join(', ', @t), "\n"; + }); + +$zinc->focusFollowsMouse(); + MainLoop(); -- cgit v1.1