aboutsummaryrefslogtreecommitdiff
path: root/Perl/demos/Tk/demos/zinc_lib/triangles.pl
diff options
context:
space:
mode:
Diffstat (limited to 'Perl/demos/Tk/demos/zinc_lib/triangles.pl')
-rw-r--r--Perl/demos/Tk/demos/zinc_lib/triangles.pl56
1 files changed, 56 insertions, 0 deletions
diff --git a/Perl/demos/Tk/demos/zinc_lib/triangles.pl b/Perl/demos/Tk/demos/zinc_lib/triangles.pl
new file mode 100644
index 0000000..7114c7e
--- /dev/null
+++ b/Perl/demos/Tk/demos/zinc_lib/triangles.pl
@@ -0,0 +1,56 @@
+#!/usr/bin/perl
+# $Id$
+# these simple samples have been developped by C. Mertz mertz@cena.fr and N. Banoun banoun@cena.fr
+
+use Tk;
+use Tk::Zinc;
+use strict;
+
+
+my $defaultfont = '-adobe-helvetica-bold-r-normal-*-120-*-*-*-*-*-*';
+my $mw = MainWindow->new();
+my $zinc = $mw->Zinc(-width => 700, -height => 300,
+ -font => "10x20", # usually fonts are sets in resources
+ # but for this example it is set in the code!
+ -render => 1,
+ -borderwidth => 3, -relief => 'sunken',
+ )->pack;
+
+# 6 equilateral triangles around a point
+$zinc->add('text', 1,
+ -position => [ 5,10 ],
+ -text => "Triangles item without transparency");
+
+my ($x0,$y0) = (200,150);
+my @coords=($x0,$y0);
+for my $i (0..6) {
+ my $angle = $i * 6.28/6;
+ push @coords, ($x0 + 100 * cos ($angle), $y0 - 100 * sin ($angle) );
+}
+
+my $tr1 = $zinc->add('triangles', 1,
+ \@coords,
+ -fan => 1,
+ -colors => ['white', 'yellow', 'magenta', 'blue', 'cyan', 'green', 'red', 'yellow'],
+ -visible => 1,
+ );
+
+$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
+my $tr2 = $zinc->clone($tr1);
+$zinc->translate($tr2,300,0);
+$zinc->itemconfigure($tr2,
+# -colors => ['#00ed00','#ffff00:50','#006aed:50','#e00000:50'], # this lines bugs zincGL 3.2.3b
+ -colors => ['white:50', 'yellow:50', 'magenta:50', 'blue:50', 'cyan:50', 'green:50', 'red:50', 'yellow:50'],
+ );
+
+
+
+MainLoop;
+
+
+