From 35c0ddffe17567ac70b1f19d38d5d9f9c557b1f5 Mon Sep 17 00:00:00 2001 From: lecoanet Date: Fri, 25 Jan 2002 10:07:25 +0000 Subject: *** empty log message *** --- sandbox/lines.pl | 48 +++++++++++++++++++++++++ sandbox/testrect.pl | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++ sandbox/testshape.pl | 29 +++++++++++++++ sandbox/triangles.pl | 66 +++++++++++++++++++++++++++++++++++ 4 files changed, 242 insertions(+) create mode 100644 sandbox/lines.pl create mode 100644 sandbox/testrect.pl create mode 100644 sandbox/testshape.pl create mode 100644 sandbox/triangles.pl (limited to 'sandbox') diff --git a/sandbox/lines.pl b/sandbox/lines.pl new file mode 100644 index 0000000..d4ca52d --- /dev/null +++ b/sandbox/lines.pl @@ -0,0 +1,48 @@ +#!/usr/bin/perl -w + +use Tk; +use Tk::Zinc; + +#!/usr/bin/perl -w + +use Tk; +use Tk::Zinc; +use Controls; +use Tk::Photo; +require Tk::PNG; + +$mw = MainWindow->new(); +$logo = $mw->Photo(-file => "logo.gif"); +$papier = $mw->Photo(-file => "texture-paper.xpm"); +$penguin = $mw->Photo(-format => 'png', + -file => "xpenguin.png"); + +$top = 1; +$zinc = $mw->Zinc(-render => 1, + -borderwidth => 0, + -highlightthickness => 0, + -relief => 'sunken', + -takefocus => 1, +# -tile => $papier + ); +$zinc->pack(-expand => 1, -fill => 'both'); +$zinc->configure(-width => 500, -height => 500); + +$view = $zinc->add('group', $top, -tags => "controls"); +$mp3 = $zinc->add('curve', $view, [20, 280, 100, 430, 200, 430], + -linewidth => 9, + -closed => 0, + -linestyle => 'dashed', + -joinstyle => 'round', +# -firstend => [3, 12, 8], +# -lastend => "12 12 8", + -capstyle => 'round', + -linecolor => 'red', + -linealpha => 100); + +new Controls($zinc); +$mw->Tk::bind('

', sub { print "perfs: ", join(',', $zinc->monitor()), "\n" }); +$mw->Tk::bind('', sub { $zinc->remove($arc); }); +$mw->Tk::bind('', sub { exit(0); }); +$zinc->focusFollowsMouse(); +MainLoop(); diff --git a/sandbox/testrect.pl b/sandbox/testrect.pl new file mode 100644 index 0000000..aac1959 --- /dev/null +++ b/sandbox/testrect.pl @@ -0,0 +1,99 @@ +#!/usr/bin/perl -w + +use Tk; +use Tk::Zinc; + +use Controls; + +$mw = MainWindow->new(); + + +################################################### +# creation zinc +################################################### +$top = 1; +$zinc_width = 800; +$zinc_height = 500; + +$zinc = $mw->Zinc(-backcolor => 'gray65', -relief => 'sunken'); +$zinc->pack(-expand => 1, -fill => 'both'); +$zinc->configure(-width => $zinc_width, -height => $zinc_height); + +#$zinc->configure(-drawbboxes => 1); + +#print "cells ", $zinc->cells(), " visual ", $zinc->visual(), " ", $zinc->visualsavailable(), "\n"; + +$zinc->scale($top, 1, -1); +$view = $zinc->add('group', $top, -tags => ["controls"]); +$zinc->translate($view, 300, -200); +$view2 = $zinc->add('group', $top); +$zinc->translate($view2, 100, -50); + + +#$rect0 = $zinc->add('rectangle', $view [100, -105, 200, -305], +# -filled => t, +# -fillcolor => "white|cadetblue3"); + +$color1 = 'darkslateblue'; +$color2 = '#f0ffff'; +$gangle = 0; +$shades = 8; +$rect1 = $zinc->add('rectangle', $view, [-50, 100, 50, -100], + -filled => 1, + -relief => 'flat', + -linewidth => 1, + -fillpattern => 'AlphaStipple7', + -fillcolor => "$color1|$color2/$gangle%$shades"); +# +# Mire +$zinc->add('curve', $view, [-10, 0, 10, 0], + -linecolor => 'red'); +$zinc->add('curve', $view, [0, -10, 0, 10], + -linecolor => 'red'); + +$handle = $zinc->add('arc', $view, [-3, -106, 3, -112], + -filled => 1, + -fillcolor => 'red'); +$zinc->bind($handle, '', \&adjustcontrol); + +sub adjustcontrol { + my $ev = $zinc->XEvent(); + my $x; + my $y; + my ($xo, $yo, $xc, $yc) = $zinc->coords($rect1); + + ($x, $y) = $zinc->transform($view, [$ev->x, 0]); + if ($x < $xo) { + $x = $xo; + } + elsif ($x > $xc) { + $x = $xc; + } + $zinc->coords($handle, [$x - 3, $yc-6, $x + 3, $yc-12]); + $x = ($x - $xo)*100/($xc-$xo); + $zinc->itemconfigure($rect1, + -fillcolor => "$color1 0 $x|$color2/$gangle%$shades"); +} + +# +# 72 61 139 = DarkSlateBlue +# +# 240 255 255 = azure +# +#set rect2 [.r add rectangle $view "202 -320 302 -350" -filled t -fillcolor darkgray -linewidth 2] + +#set rect3 [.r add rectangle $view "250 -100 350 -300" -filled t -relief raised -linewidth 4 -fillcolor "white|cadetblue3"] + +#set rect4 [.r add rectangle $view2 "0 0 101 -81" -linewidth 2 -linecolor darkgray -filled t] +#.r itemconfigure $rect4 -fillcolor "white|darkslateblue" + +#set rect5 [.r add rectangle $view2 "0 0 101 -81" -linewidth 2 -linecolor darkgray -filled t -fillcolor blue -relief sunken] +#.r translate $rect5 0 -90 + + +new Controls($zinc); + +MainLoop(); + + +1; diff --git a/sandbox/testshape.pl b/sandbox/testshape.pl new file mode 100644 index 0000000..9d6a76e --- /dev/null +++ b/sandbox/testshape.pl @@ -0,0 +1,29 @@ +#!/usr/bin/perl -w + +use Tk; +use Tk::Zinc; +use Controls; + +$mw = MainWindow->new(); + +$top = 1; +$zinc = $mw->Zinc(-render => 1, + -borderwidth => 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); + +$view = $zinc->add('group', $top, -tags => "controls"); + +new Controls($zinc); + +MainLoop(); diff --git a/sandbox/triangles.pl b/sandbox/triangles.pl new file mode 100644 index 0000000..84555b6 --- /dev/null +++ b/sandbox/triangles.pl @@ -0,0 +1,66 @@ +#!/usr/bin/perl -w + +use Tk; +use Tk::Zinc; +use Controls; +use Tk::Photo; +require Tk::PNG; + +$mw = MainWindow->new(); +$logo = $mw->Photo(-file => "logo.gif"); +$papier = $mw->Photo(-file => "texture-paper.xpm"); +$penguin = $mw->Photo(-format => 'png', + -file => "xpenguin.png"); + +$top = 1; +$zinc = $mw->Zinc(-render => 1, + -borderwidth => 0, + -highlightthickness => 0, + -relief => 'sunken', + -takefocus => 1, + -tile => $papier); +$zinc->pack(-expand => 1, -fill => 'both'); +$zinc->configure(-width => 500, -height => 500); +$gr1 = $zinc->add('group', $top); +$clip = $zinc->add('arc', $gr1, [50, 50, 399, 399], + -filled => 1, + -fillcolor => 'Pink:40', +# -fillpattern => 'AlphaStipple4', + -linewidth => 0); +#$zinc->itemconfigure($gr1, -clip => $clip); +$gr2 = $zinc->add('group', $gr1); +$clip2 = $zinc->add('rectangle', $gr2, [200, 200, 450, 300], + -filled => 1, +# -fillcolor => 'white:100|white:0', + -fillcolor => 'white:100 0|black:100 100/90', +# -fillcolor => 'white 0 |blue 20|blue 80|black:0 100/270', + -linewidth => 0); +#$zinc->itemconfigure($gr2, -clip => $clip2); +$view = $zinc->add('group', $gr2, -tags => "controls"); +$zinc->lower($clip); +$zinc->lower($clip2); + +new Controls($zinc); + +$cv2 = $zinc->add('curve', $view, [], + -linewidth => 2); +$cv3 = $zinc->add('curve', $view, [], + -linewidth => 2); + +$tri2 = $zinc->add('triangles', $view, [50, 50, 300, 50, 150, 150, 300, 150], + -colors => ['tan:50', '', '', 'red']); +$zinc->contour($cv2, 'union', $tri2); + +$tri3 = $zinc->add('triangles', $view, [150, 150, 50, 50, 150, 50, 300, 50], + -colors => ['grey50', 'blue', 'red', 'yellow'], + -fan => 1); +$zinc->contour($cv3, 'union', $tri3); +$zinc->translate($tri3, 0, 300); +$zinc->translate($cv3, 0, 300); + +$zinc->monitor(1); +$mw->Tk::bind('

', sub { print "perfs: ", join(',', $zinc->monitor()), "\n" }); +$mw->Tk::bind('', sub { $zinc->remove($arc); }); +$mw->Tk::bind('', sub { exit(0); }); +$zinc->focusFollowsMouse(); +MainLoop(); -- cgit v1.1