aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormertz2003-06-24 15:12:32 +0000
committermertz2003-06-24 15:12:32 +0000
commitb54c2e3875bdf007b1b216e946a34c36b2d57224 (patch)
tree9005f9750c4e54b6d25f97061b6dcf4e21ca5619
parent8b26b4c2416759094fe34ba80595a5588e706f5f (diff)
downloadtkzinc-b54c2e3875bdf007b1b216e946a34c36b2d57224.zip
tkzinc-b54c2e3875bdf007b1b216e946a34c36b2d57224.tar.gz
tkzinc-b54c2e3875bdf007b1b216e946a34c36b2d57224.tar.bz2
tkzinc-b54c2e3875bdf007b1b216e946a34c36b2d57224.tar.xz
Some slight cleaning of Graphics in function names, export etc....
-rw-r--r--Perl/Zinc/Graphics.pm95
-rw-r--r--Perl/demos/Tk/demos/zinc_lib/testGraphics.pl32
2 files changed, 64 insertions, 63 deletions
diff --git a/Perl/Zinc/Graphics.pm b/Perl/Zinc/Graphics.pm
index bd312c8..22af410 100644
--- a/Perl/Zinc/Graphics.pm
+++ b/Perl/Zinc/Graphics.pm
@@ -5,43 +5,58 @@
# module de fonctions graphiques
#
#-----------------------------------------------------------------------------------
-# Gestion de ressources globales : gradiants zinc (couleurs et dégradés nommés)
+# Gestion de ressources globales : gradients zinc (couleurs et dégradés nommés)
# patterns (fichiers bitmap X11)
# textures (fichiers texture)
# images (fichiers GIF, JPEG, PNG)
#-----------------------------------------------------------------------------------
-# Fonctions Zinc : buildZincItem (réalisation d'un item zinc à partir d'une table de description)
+# Functions to create complexe graphic component :
+# buildZincItem (réalisation d'un item zinc à partir d'une table de description)
#
-# Fonctions géométriques : roundedRectangleCoords
-# HippoCoords
+# Function to compute complexe geometrical forms :
+# roundedRectangleCoords
+# hippodromeCoords
# polygonCoords
# roundedCurveCoords
# polylineCoords
# tabBoxCoords
-# roundedAngle
-# roundedCurve
+# pathLineCoords
+#
+# Geometrical Functions :
# perpendicularPoint
# lineAngle
# vertexAngle
# arc_pts
# rad_point
#
-# Fonctions picturales : setGradiants
+# Pictorial Functions :
+# setGradients
# getPattern
# getTexture
# getImage
# init_pixmaps
+# hexaRGBcolor
+# createGraduate
#-----------------------------------------------------------------------------------
# Authors: Jean-Luc Vinot <vinot@cena.fr>
#
# $Id:
#-----------------------------------------------------------------------------------
-package Graphics;
+package Zinc::Graphics;
require Exporter;
@ISA = qw(Exporter);
-@EXPORT = qw(&buildZincItem &setGradiants &getTexture &getPattern &getImage &roundedAngle &roundedCurveCoords
- &polylineCoords &polygonCoords &TabBoxCoords &pathLineCoords &rad_point &arc_pts);
+@EXPORT = qw(&buildZincItem
+
+ &roundedRectangleCoords &hippodromeCoords &polygonCoords
+ &roundedCurveCoords &polylineCoords &tabBoxCoords &pathLineCoords
+
+ &perpendicularPoint &lineAngle &vertexAngle &rad_point &arc_pts
+
+
+
+ &setGradients &getPattern &getTexture &getImage &init_pixmaps &hexaRGBcolor &createGraduate
+ );
use strict;
use Carp;
@@ -51,13 +66,11 @@ use Math::Trig;
# constante facteur point directeur
my $const_ptd_factor = .5523;
-my @Gradiants;
+my @Gradients;
my %textures;
my %images;
my %bitmaps;
-my $font_7 = '-cenapii-bleriot mini-book-r-normal--7-70-75-75-p-*-iso8859-15';
-
#-----------------------------------------------------------------------------------
# Graphics::buildZincItem
@@ -109,7 +122,7 @@ sub buildZincItem {
} elsif ($itemtype eq 'hippodrome') {
$itemtype = 'curve';
$style->{'-params'}->{'-closed'} = 1;
- $coords = &HippoCoords($coords, %{$style});
+ $coords = &hippodromeCoords($coords, %{$style});
} elsif ($itemtype eq 'polygone') {
$itemtype = 'curve';
@@ -253,7 +266,7 @@ sub metaCoords {
$pts = &polygonCoords($coords, %options);
} elsif ($type eq 'hyppodrome') {
- $pts = &hippoCoords($coords, %options);
+ $pts = &hippodromeCoords($coords, %options);
} elsif ($type eq 'polyline') {
$pts = &polylineCoords($coords, %options);
@@ -339,7 +352,7 @@ sub roundedRectangleCoords {
#-----------------------------------------------------------------------------------
-# Graphics::HippoCoords
+# Graphics::hippodromeCoords
# calcul des coords d'un hippodrome
# paramètres :
# coords : coordonnées du rectangle exinscrit
@@ -348,7 +361,7 @@ sub roundedRectangleCoords {
# -corners : liste des raccords de sommets [0|1] par défaut [1,1,1,1]
# -trunc : troncatures [left|right|top|bottom|both]
#-----------------------------------------------------------------------------------
-sub HippoCoords {
+sub hippodromeCoords {
my ($coords, %options) = @_;
my ($x0, $y0, $xn, $yn) = ($coords->[0]->[0], $coords->[0]->[1],
$coords->[1]->[0], $coords->[1]->[1]);
@@ -435,8 +448,11 @@ sub polygonCoords {
}
}
+
+
#-----------------------------------------------------------------------------------
# Graphics::roundedAngle
+# THIS FUNCTION IS NO MORE USED, NEITHER EXPORTED
# curve d'angle avec raccord circulaire
# paramètres :
# zinc : widget
@@ -456,27 +472,6 @@ sub roundedAngle {
$parentgroup = 1 if (!defined $parentgroup);
- # temporaire -> visibilité de l'arc 'conique' correspondant
- $zinc->add('arc', $parentgroup,
- [[$cx0 - $radius, $cy0 - $radius],[$cx0 + $radius, $cy0 + $radius]],
- -priority => 10,
- -linecolor => '#9999ff',
- -filled => 0,
- -visible => 1,
- -linewidth => 2,
- );
-
- # temporaire
- $zinc->add('text', $parentgroup,
- -position => [$cx0 - $radius + 2, $cy0],
- -priority => 20,
- -color => '#0000ff',
- -text => $angle."°",
- -font => $font_7,
- -alignment => 'left',
- -anchor => 'w',
- );
-
$zinc->add('curve', $parentgroup,
[$pt0,@{$corner_pts},$pt2],
-closed => 0,
@@ -877,7 +872,7 @@ sub buidTabBox {
}
#-----------------------------------------------------------------------------------
-# TabBoxCoords
+# tabBoxCoords
# Calcul des shapes de boites à onglets
#
# coords : coordonnées rectangle de la bounding box
@@ -892,7 +887,7 @@ sub buidTabBox {
# -radius <n> : rayon des arrondis d'angle
# -overlap <n> : distance de recouvrement des onglets
#-----------------------------------------------------------------------------------
-sub TabBoxCoords {
+sub tabBoxCoords {
my ($coords, %options) = @_;
my ($x0, $y0, $xn, $yn) = (@{$coords->[0]}, @{$coords->[1]});
my (@shapes, @titles_coords);
@@ -1053,21 +1048,21 @@ sub TabBoxCoords {
#-----------------------------------------------------------------------------------
-# RESOURCES GRAPHIQUES GRADIANTS, PATTERNS, TEXTURES, IMAGES...
+# RESOURCES GRAPHIQUES GRADIENTS, PATTERNS, TEXTURES, IMAGES...
#-----------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------
-# Graphics::setGradiants
-# création de gradiant nommés Zinc
+# Graphics::setGradients
+# création de gradient nommés Zinc
#-----------------------------------------------------------------------------------
-sub setGradiants {
+sub setGradients {
my ($zinc, $grads) = @_;
- # initialise les gradiants de taches
- unless (@Gradiants) {
- while (my ($name, $gradiant) = each( %{$grads})) {
- # création des gradiants nommés
- $zinc->gname($gradiant, $name);
- push(@Gradiants, $name);
+ # initialise les gradients de taches
+ unless (@Gradients) {
+ while (my ($name, $gradient) = each( %{$grads})) {
+ # création des gradients nommés
+ $zinc->gname($gradient, $name);
+ push(@Gradients, $name);
}
}
}
diff --git a/Perl/demos/Tk/demos/zinc_lib/testGraphics.pl b/Perl/demos/Tk/demos/zinc_lib/testGraphics.pl
index c79ace0..55a5516 100644
--- a/Perl/demos/Tk/demos/zinc_lib/testGraphics.pl
+++ b/Perl/demos/Tk/demos/zinc_lib/testGraphics.pl
@@ -11,7 +11,7 @@
use Tk;
use Tk::Zinc;
-use Graphics;
+use Zinc::Graphics;
use Getopt::Long;
use strict 'vars';
@@ -23,9 +23,11 @@ my ($dx, $dy);
my $tabanchor = 'n';
my $tabalign = 'left';
-my $font_9b = '-cenapii-bleriot mini-bold-r-normal--9-90-75-75-p-75-iso8859-15';
+my $font_9b = '8x13bold';
+# the original font is not standard, even if it is fully free:
+# my $font_9b = '-cenapii-bleriot mini-bold-r-normal--9-90-75-75-p-75-iso8859-15';
-my %gradset = (# gradiants zinc
+my %gradset = (# gradients zinc
'boitonglet' => '=axial 0|#ff7777|#ffff99',
'roundrect1' => '=axial 270|#a7ffa7;70 0|#ffffff;90 5|#00bd00;80 8|#b7ffb7;50 80|#ffffff;70 91|#00ac00;70 95|#006700;60 100',
'roundrect2' => '=axial 270|#00bd00;80 |#d7ffd7;60',
@@ -1329,8 +1331,8 @@ my $zinc = $mw->Zinc(-render => 1,
$zinc->pack(-fill => 'both', -expand => 1);
-# initialise les gradiants nommés
-&setGradiants($zinc, \%gradset);
+# initialise les gradients nommés
+&setGradients($zinc, \%gradset);
# initialise les images de fontes
while (my ($anchor, $table) = each(%tabtable)) {
@@ -1356,7 +1358,7 @@ $zinc->add('text', 1,
);
# Création des pages d'exemples
-my ($shapes, $tcoords) = &TabBoxCoords([[-315, -210],[315, 210]],
+my ($shapes, $tcoords) = &tabBoxCoords([[-315, -210],[315, 210]],
-numpages => 7,
-overlap => 2,
-radius => 8,
@@ -1514,11 +1516,15 @@ sub selectDivider {
if ($divname eq 'div2') {
my $fontname = $tabtable{$tabanchor}->{'-names'}->[$numpage];
- my $fontimage = $tabtable{$tabanchor}->{'-images'}->[$numpage];
- $zinc->itemconfigure("($divname && fontname)", -text => $fontname);
+ my $firstLetter = substr($fontname,0,1);
+ my $lcFirstLetter = lc($firstLetter);
+# my $fontimage = $tabtable{$tabanchor}->{'-images'}->[$numpage];
+ $zinc->itemconfigure("($divname && fontname)",
+ -text => $fontname.
+ ("\n".($firstLetter x 20)."\n". ($lcFirstLetter x 20))x4);
$zinc->raise("($divname && fontname)");
- $zinc->itemconfigure("($divname && fontimage)", -image => $fontimage);
- $zinc->raise("($divname && fontimage)");
+# $zinc->itemconfigure("($divname && fontimage)", -image => $fontimage);
+# $zinc->raise("($divname && fontimage)");
}
}
@@ -1555,7 +1561,7 @@ sub clickSelector {
-overlap => 3,
);
- my ($shapes, $tcoords) = &TabBoxCoords([[-240, -140], [240, 120]], %tabparams);
+ my ($shapes, $tcoords) = &tabBoxCoords([[-240, -140], [240, 120]], %tabparams);
for (my $index = 7; $index >= 0; $index--) {
my $divgroup = $zinc->group("(div2 && $index && intercalaire)");
@@ -1647,7 +1653,7 @@ sub buildTabBox {
my $coords = delete $style->{'-coords'};
my $table = $tabtable{$style->{'-anchor'}};
my $titles = $style->{'-tabtitles'};
- my ($shapes, $tcoords, $invert) = &TabBoxCoords($coords, %{$style});
+ my ($shapes, $tcoords, $invert) = &tabBoxCoords($coords, %{$style});
my $k = ($invert) ? scalar @{$shapes} : -1;
foreach my $shape (reverse @{$shapes}) {
$k += ($invert) ? -1 : +1;
@@ -1682,7 +1688,7 @@ sub buildTabBox {
-text => $table->{'-names'}->[0],
-font => $font_9b,
-alignment => 'left',
- -anchor => 'w',
+ -anchor => 'nw',
-color => '#000000',
-priority => 500,
-tags => [$tags[0], 'fontname'],