aboutsummaryrefslogtreecommitdiff
path: root/Perl/debug
diff options
context:
space:
mode:
Diffstat (limited to 'Perl/debug')
-rw-r--r--Perl/debug/LogoZinc.pm405
1 files changed, 132 insertions, 273 deletions
diff --git a/Perl/debug/LogoZinc.pm b/Perl/debug/LogoZinc.pm
index 7e25d35..f32fb6d 100644
--- a/Perl/debug/LogoZinc.pm
+++ b/Perl/debug/LogoZinc.pm
@@ -1,11 +1,13 @@
#!/usr/bin/perl
#---------------------------------------------------------------
+# Project : Harmony
+# Module : Harmony
# File : LogoZinc.pm
#
-# Copyright (C) 2001-2002
+# Copyright (C) 2001
# Centre d'Études de la Navigation Aérienne
# Authors: Vinot Jean-Luc <vinot@cena.fr>
-# $Id$
+#
#---------------------------------------------------------------
package LogoZinc;
@@ -17,81 +19,75 @@ use Math::Trig;
Construct Tk::Widget 'LogoZinc';
-my %builder = (-shape => {-geom => [['point', 0, 0],
- ['lineto', 106, 0],
- ['lineto', 0, 58],
- ['lineto', 16, -18],
- ['lineto', 34, 0],
- ['lineto', -25, 29],
- ['lineto', 22, 30],
- ['lineto', 50, -58],
- ['lineto', -48, 0],
- ['lineto', 0, -42],
- ['lineto', 64, 0],
- ['moveto', 0, 34],
- ['arc', 34, 34, 270, 135, 5],
- ['lineto', -44, 50],
- ['lineto', 44, 0],
- ['lineto', 0, -18],
- ['moveto', 50, 0],
- ['arc', 50, 50, 180, 154, 5],
- ['moveto', 50, 31],
- ['arc', 56, 56, 210, 60, 5],
- ['lineto', 0, 42],
- ['lineto', -2, 0],
- ['moveto', 0, 14],
- ['arc', 14, 14, 270, -180, -5],
- ['lineto', 14, 0],
- ['lineto', 0, 42],
- ['lineto', -14, 0],
- ['moveto', 0, -56],
- ['arc', 56, 56, 90, 50, 5],
- ['lineto', 0, 20],
- ['lineto', -40, 0],
- ['lineto', 0, -59],
- ['moveto', -8, 0],
- ['arc', 8, 8, 360, -180, -5],
- ['lineto', 0, 59],
- ['lineto', -38, 0],
- ['lineto', 0, -18],
- ['moveto', -8, 0],
- ['arc', 8, 10, 360, -180, -5],
- ['lineto', 0, 18],
- ['lineto', -51, 0],
- ['moveto', 0, -34],
- ['arc', 34, 34, 90, 108, 4],
- ['lineto', -28, 0],
- ['lineto', -16, -24],
- ['lineto', 0, 24],
- ['lineto', -30, 0],
- ['lineto', 0, -64],
- ['lineto', -22, 0],
- ['lineto', 0, 64],
- ['lineto', -32, 0],
- ['lineto', 0, -64],
- ['lineto', -20, 0],
- ],
- -linewidth => 3,
- -linecolor => '#000000;70',
-# -fillcolor => '#ffffff 0 |#66848c 96|#7192aa 100',
- -fillcolor => '=axial 270 |#ffffff 0 |#66848c 96|#7192aa 100',
- -shadow => {-dxy => [6, 6],
- -fillcolor => '#000000;18',
- },
- },
-
- -point => {-posi => [240, 96],
- -alpha => 72,
- -geom => [['arc', 20, 20, 0, 360, 5]],
- -linewidth => 1,
- -linecolor => '#a10000;80',
- -fillcolor => '=radial -66 -66 |#ffffff;100 0|#f70000;100 48|#900000;100 80|#ab0000;100 100',
- -shadow => {-dxy => [5, 5],
-# -fillcolor => '#770000;64 0|#770000;70 78|#770000;0 100',
- -fillcolor => '=path -50 -50 |#770000;64 0|#770000;70 78|#770000;0 100',
- },
- },
- );
+my @Gradiants;
+
+# paramètres de construction graphique
+my %builder = (-gradset => {'logoshape' => '=axial 270 |#ffffff;100 0 28|#66848c;100 96|#7192aa;100 100',
+ 'logopoint' => '=radial -20 -20 |#ffffff;100 0|#f70000;100 48|#900000;100 80|#ab0000;100 100',
+ 'logoptshad' => '=path 0 0 |#770000;64 0|#770000;70 78|#770000;0 100',
+ },
+
+ -shape => {-form => {-itemtype => 'curve',
+ -coords => [[0, 0],[106, 0],[106, 58],[122, 41],[156, 41],[131, 69],
+ [153, 99],[203, 41],[155, 41],[155, 0],[218, 0],[240, 0, 'c'],
+ [252, 17, 'c'],[252, 34],[252, 40, 'c'],[249, 50, 'c'],
+ [244, 56],[202, 105],[246, 105],[246, 87],[246, 60, 'c'],
+ [271, 37, 'c'],[297, 37],[323, 37, 'c'],[342, 57, 'c'],[344, 68],
+ [347, 64, 'c'],[350, 60, 'c'],[353, 56],[363, 46, 'c'],[375, 37, 'c'],
+ [395, 37],[395, 79],[393, 79],[385, 79, 'c'],[379, 86, 'c'],
+ [379, 93],[379, 100, 'c'],[385, 107, 'c'],[393, 107],[409, 107],
+ [409, 148],[397, 148],[378, 148, 'c'],[364, 144, 'c'],[354, 133],
+ [346, 124],[346, 148],[305, 148],[305, 87],[305, 83, 'c'],[301, 79, 'c'],
+ [297, 79],[293, 79, 'c'],[289, 83, 'c'],[289, 87],[289, 150],[251, 150],
+ [251, 130],[251, 126, 'c'],[247, 122, 'c'],[243, 122],[239, 122, 'c'],
+ [235, 126, 'c'],[235, 130],[235, 150],[176, 150],[154, 150,'c'],
+ [146, 131,'c'],[146, 114],[148, 105],[120, 105],[104, 81],[104, 105],
+ [74, 105],[74, 41],[52, 41],[52, 105],[20, 105],[20, 41],[0, 41],
+ ],
+
+ -params => {-priority => 50,
+ -linewidth => 3,
+ -linecolor => '#000000;100',
+ -filled => 1,
+ -closed => 0,
+ -fillcolor => 'logoshape',
+ },
+ },
+
+ -shadow => {-clone => '-form',
+ -translate => [6, 6],
+ -params => {-fillcolor => '#000000;18',
+ -linewidth => 0,
+ -priority => 20,
+ },
+ },
+ },
+
+ -point => {-coords => [240, 96],
+ -params => {-alpha => 80,
+ -priority => 100,
+ },
+
+ -form => {-itemtype => 'arc',
+ -coords => [[-20, -20], [20, 20]],
+ -params => {-priority => 50,
+ -filled => 1,
+ -linewidth => 1,
+ -linecolor => '#a10000;100',
+ -fillcolor => 'logopoint',
+ -closed => 1,
+ },
+ },
+
+ -shadow => {-clone => '-form',
+ -translate => [5, 5],
+ -params => {-fillcolor => 'logoptshad',
+ -linewidth => 0,
+ -priority => 20,
+ },
+ },
+ },
+ );
@@ -109,220 +105,83 @@ sub new {
$self->{'-priority'} = (exists $params{'-priority'}) ? $params{'-priority'} : 500;
$self->{'-position'} = (exists $params{'-position'}) ? $params{'-position'} : [0, 0];
$self->{'-scale'} = (exists $params{'-scale'}) ? $params{'-scale'} : [1, 1];
-
+
$self->drawLogo();
-
+
return bless $self, $type;
}
sub drawLogo {
- my ($self) = @_;
- my $zinc = $self->{'-widget'};
- my $parent = $self->{'-parent'};
- my $priority = $self->{'-priority'};
-
- # création du groupe
- my ($x, $y) = @{$self->{'-position'}};
- my ($xs, $ys) = @{$self->{'-scale'}};
-
- my $logogroup = $zinc->add('group', $parent, -priority => $priority);
- $zinc->coords($logogroup, [$x, $y]);
-
- my $group = $zinc->add('group', $logogroup);
- $zinc->scale($group, $xs, $ys);
-
- # création de l'item
- my $shapeconf = $builder{'-shape'};
- my @form_params = @{$shapeconf->{'-geom'}};
-
- # ombre portée
- my ($dx, $dy) = @{$shapeconf->{'-shadow'}->{'-dxy'}};
- my $shadow_pts = $self->polyLine($dx, $dy, @form_params);
- $zinc->add('curve', $group,
- $shadow_pts,
- -closed => 1,
- -filled => 1,
- -fillcolor => $shapeconf->{'-shadow'}->{'-fillcolor'},
- -linewidth => 0,
- );
-
- my $shape_pts = $self->polyLine(0, 0, @form_params);
- my $linewidth = int(($shapeconf->{'-linewidth'} * $xs) + 0.5);
- $linewidth = 1 if $linewidth <= 0;
-
- $zinc->add('curve', $group,
- $shape_pts,
- -tags => ['letters'],
- -closed => 0,
- -filled => 1,
- -fillcolor => $shapeconf->{'-fillcolor'},
- -linewidth => $linewidth,
- -linecolor => $shapeconf->{'-linecolor'},
- );
-
- my $pointconf = $builder{'-point'};
- my $ptgroup = $zinc->add('group', $group, -alpha => $pointconf->{'-alpha'});
- $zinc->coords($ptgroup, $pointconf->{'-posi'});
-
- @form_params = @{$pointconf->{'-geom'}};
- # ombre portée
- ($dx, $dy) = @{$pointconf->{'-shadow'}->{'-dxy'}};
- $shadow_pts = $self->polyLine($dx, $dy, @form_params);
- $zinc->add('curve', $ptgroup,
- $shadow_pts,
- -closed => 1,
- -filled => 1,
- -fillcolor => $pointconf->{'-shadow'}->{'-fillcolor'},
- -linewidth => 0,
- );
-
- my $pt_pts = $self->polyLine(0, 0, @form_params);
- $zinc->add('curve', $ptgroup,
- $pt_pts,
- -tags => ['point'],
- -closed => 1,
- -filled => 1,
- -fillcolor => $pointconf->{'-fillcolor'},
- -linewidth => $pointconf->{'-linewidth'},
- -linecolor => $pointconf->{'-linecolor'},
- );
-
-
-
-}
-
-sub polyLine {
- my ($self, $x0, $y0, @faces) = @_;
- my @pts = ();
- my @previous = ($x0, $y0);
-
- return undef if ($#faces == -1);
-
-
- foreach (@faces) {
- my ($type, $dx, $dy, $angle, $extend, $astep) = @{$_};
-
- if ($type eq 'moveto') {
- @previous = ($previous[0] + $dx, $previous[1] + $dy);
-
- } elsif ($type eq 'point') {
- push (@pts, ($dx, $dy));
-
- } elsif ($type eq 'lineto') {
- @previous = ($previous[0] + $dx, $previous[1] + $dy);
- push (@pts, @previous);
-
- } else {
- next if ($dx == 0 or $dy == 0);
-
- my $xc = $previous[0];
- my $yc = $previous[1];
-
- if ($dx == $dy) {
- push (@pts, &arc_pts($xc, $yc, $dx, $angle, $extend, $astep));
-
- } else {
- if ($dx > $dy) {
- my $z = $dy / $dx;
- push (@pts, &ove_pts($xc, $yc, $dx, $angle, $extend,
- $astep, $z, 'y'));
-
-
- } else {
- my $z = $dx / $dy;
- push (@pts, &ove_pts($xc, $yc, $dy, $angle, $extend,
- $astep, $z, 'x'));
-
-
- }
+ my ($self) = @_;
+ my $zinc = $self->{'-widget'};
+ my $parent = $self->{'-parent'};
+ my $priority = $self->{'-priority'};
- }
- my $numpts = scalar(@pts);
- @previous = ($pts[$numpts - 2],$pts[$numpts - 1]);
- }
+ if ($builder{'-gradset'}) {
+ while (my ($name, $gradiant) = each( %{$builder{'-gradset'}})) {
+ # création des gradiants nommés
+ $zinc->gname($gradiant, $name);
+ push(@Gradiants, $name);
}
+ }
+
+ # création des groupes logo
+ # logogroup : groupe de coordonnées
+ my $logogroup = $self->{'-item'} = $zinc->add('group', $parent, -priority => $priority);
+ $zinc->coords($logogroup, $self->{'-position'}) if ($self->{'-position'});
+
+ # group de scaling
+ my $group = $self->{'-scaleitem'} = $zinc->add('group', $logogroup);
+ $zinc->scale($group, @{$self->{'-scale'}}) if ($self->{'-scale'});
+
+
+ # création de l'item shape (Zinc)
+ my $formstyle = $builder{'-shape'}->{'-form'};
+ $self->ajustLineWidth($formstyle->{'-params'});
+ my $shape = $zinc->add('curve', $group,
+ $formstyle->{'-coords'},
+ %{$formstyle->{'-params'}},
+ );
+
+ # ombre portée de la shape
+ my $shadstyle = $builder{'-shape'}->{'-shadow'};
+ my $shadow = $zinc->clone($shape, %{$shadstyle->{'-params'}});
+ $zinc->translate($shadow, @{$shadstyle->{'-translate'}}) if ($shadstyle->{'-translate'});
+
+ # réalisation du point
+ my $pointconf = $builder{'-point'};
+ my $ptgroup = $zinc->add('group', $group, %{$pointconf->{'-params'}});
+ $zinc->coords($ptgroup, $pointconf->{'-coords'});
+
+ my $pointstyle = $pointconf->{'-form'};
+ my $point = $zinc->add('arc', $ptgroup,
+ $pointstyle->{'-coords'},
+ %{$pointstyle->{'-params'}},
+ );
+
+ my $shadpoint = $zinc->clone($point, %{$shadstyle->{'-params'}});
+ $shadstyle = $pointconf->{'-shadow'};
+ $zinc->translate($shadpoint, @{$shadstyle->{'-translate'}});
- return \@pts;
-
-}
-
-
-# calcul des points constitutif d'un arc
-sub arc_pts {
- my ($x, $y, $rad, $angle, $extent, $step, $debug) = @_;
- my @pts = ();
-
-
- if ($extent > 0) {
- for (my $alpha = $angle; $alpha <= ($angle + $extent); $alpha += $step) {
- #push (@pts, &rad_point($x, $y, $rad,$alpha));
- my ($xn, $yn) = &rad_point($x, $y, $rad,$alpha);
- push (@pts, ($xn, $yn));
- print "Graphics::arc_pts a:$alpha $step xn:$xn yn:$yn\n" if $debug;
- }
- } else {
- for (my $alpha = $angle; $alpha >= ($angle + $extent); $alpha += $step) {
- push (@pts, &rad_point($x, $y, $rad,$alpha));
- }
- }
-
- return @pts;
}
-#calcul des points constitutif d'un arc d'ellipse (arc aplati)
-sub ove_pts {
- my ($x, $y, $rad, $angle, $extent, $step, $z, $axe) = @_;
- my @pts = ();
- my @arcpts = ();
-
-
- my $maxangle = $extent + $step;
- my ($cx, $cy);
-
- if ($extent >= 0) {
- for (my $alpha = $angle; $alpha <= ($angle + $extent); $alpha += $step) {
- push(@arcpts, &rad_point($x, $y, $rad, $alpha));
- }
+sub ajustLineWidth {
+ my ($self, $style, $scale) = @_;
- } else {
- for (my $alpha = $angle; $alpha >= ($angle + $extent); $alpha += $step) {
- push(@arcpts, &rad_point($x, $y, $rad, $alpha));
- }
+ if ($style->{'-linewidth'}) {
+ my ($sx, $sy) = @{$self->{'-scale'}};
+ my $linewidth = $style->{'-linewidth'};
+ if ($linewidth >= 2) {
+ my $ratio = ($sx > $sy) ? $sy : $sx;
+ $style->{'-linewidth'} = $linewidth * $ratio;
}
-
- for (my $i = 0; $i < scalar(@arcpts); $i+=2) {
- my ($zx, $zy) = ($arcpts[$i], $arcpts[$i+1]);
-
- if ($axe eq 'y') {
- my $dy = ($zy - $y) * $z;
- $zy = $y + $dy;
-
- } else {
- my $dx = ($zx - $x) * $z;
- $zx = $x + $dx;
- }
-
- push (@pts, ($zx, $zy));
- }
-
- return @pts;
+ }
}
-sub rad_point {
- my ($x, $y, $rad, $angle) = @_;
- my $alpha = deg2rad($angle);
-
- my $xpt = $x + ($rad * cos($alpha));
- my $ypt = $y + ($rad * sin($alpha));
-
- return ($xpt, $ypt,);
-}
-
-
1;