aboutsummaryrefslogtreecommitdiff
path: root/Perl/Zinc
diff options
context:
space:
mode:
authorvinot2003-07-07 12:18:18 +0000
committervinot2003-07-07 12:18:18 +0000
commit9fd9b731eccb4d81f53aa915073355aa82a8c548 (patch)
tree62cf0143f6206a167af74ca249420fc9a7481e81 /Perl/Zinc
parent327b8791be1dca825b098e7f6816cf69d231d139 (diff)
downloadtkzinc-9fd9b731eccb4d81f53aa915073355aa82a8c548.zip
tkzinc-9fd9b731eccb4d81f53aa915073355aa82a8c548.tar.gz
tkzinc-9fd9b731eccb4d81f53aa915073355aa82a8c548.tar.bz2
tkzinc-9fd9b731eccb4d81f53aa915073355aa82a8c548.tar.xz
modif fonction roundedRectangleCoords
suppression des points redondants (cas extremes type hippo de points de r�f�rence confondus)
Diffstat (limited to 'Perl/Zinc')
-rw-r--r--Perl/Zinc/Graphics.pm43
1 files changed, 22 insertions, 21 deletions
diff --git a/Perl/Zinc/Graphics.pm b/Perl/Zinc/Graphics.pm
index 7eaf606..e61c682 100644
--- a/Perl/Zinc/Graphics.pm
+++ b/Perl/Zinc/Graphics.pm
@@ -143,8 +143,7 @@ sub buildZincItem {
if ($style->{'-contours'}) {
my @contours = @{$style->{'-contours'}};
my $numcontours = scalar(@contours);
- my $i;
- for ($i = 0; $i < $numcontours; $i++) {
+ for (my $i = 0; $i < $numcontours; $i++) {
# radius et corners peuvent être défini spécifiquement pour chaque contour
my ($type, $way, $coords, $radius, $corners, $corners_radius) = @{$contours[$i]};
$radius = $style->{'-radius'} if (!defined $radius);
@@ -339,10 +338,18 @@ sub roundedRectangleCoords {
[[$xn, $y2],[$xn, $y1, 'c'],[$x4, $y0, 'c'],[$x3, $y0],]);
my @pts = ();
- my $i;
- for ($i = 0; $i < 4; $i++) {
+ my $previous;
+ for (my $i = 0; $i < 4; $i++) {
if ($corners->[$i]) {
+ if ($previous) {
+ # on teste si non duplication de point
+ my ($nx, $ny) = @{$roundeds[$i]->[0]};
+ if ($previous->[0] == $nx and $previous->[1] == $ny) {
+ pop(@pts);
+ }
+ }
push(@pts, @{$roundeds[$i]});
+ $previous = $roundeds[$i]->[3];
} else {
push(@pts, $angle_pts[$i]);
@@ -431,8 +438,7 @@ sub polygonCoords {
my @pts;
# points du polygone
- my $i;
- for ($i = 0; $i < $numsides; $i++) {
+ for (my $i = 0; $i < $numsides; $i++) {
my ($xp, $yp) = &rad_point($cx, $cy, $radius, $startangle + ($anglestep*$i));
push(@pts, ([$xp, $yp]));
@@ -653,8 +659,7 @@ sub pathLineCoords {
my $next = $coords->[1];
$linewidth /= 2 if ($shifting eq 'both');
- my $i;
- for ($i = 0; $i < $numfaces; $i++) {
+ for (my $i = 0; $i < $numfaces; $i++) {
my $pt = $coords->[$i];
if (!$previous) {
@@ -955,8 +960,7 @@ sub tabBoxCoords {
($anchor eq 'w' and $alignment ne 'right')) {
if (ref($len) eq 'ARRAY') {
- my $p;
- for ($p = 0; $p < $numpages; $p++) {
+ for (my $p = 0; $p < $numpages; $p++) {
$len->[$p] *= -1;
}
} else {
@@ -1004,8 +1008,7 @@ sub tabBoxCoords {
$inverse = (($anchor eq 'n' and $alignment ne 'right') or ($anchor eq 's' and $alignment eq 'right'));
}
- my $i;
- for ($i = 0; $i < $numpages; $i++) {
+ for (my $i = 0; $i < $numpages; $i++) {
my @pts = ();
# décrochage onglet
@@ -1200,7 +1203,6 @@ sub pathGraduate {
my $type = $style->{'-type'};
my $triangles_colors;
- my $i;
if ($type eq 'linear') {
return &createGraduate($zinc, $numcolors, $style->{'-colors'}, 2);
@@ -1209,7 +1211,7 @@ sub pathGraduate {
my $colors1 = &createGraduate($zinc, $numcolors/2+1, $style->{'-colors'}->[0]);
my $colors2 = &createGraduate($zinc, $numcolors/2+1, $style->{'-colors'}->[1]);
my @colors;
- for ($i = 0; $i <= $numcolors; $i++) {
+ for (my $i = 0; $i <= $numcolors; $i++) {
push(@colors, ($colors1->[$i], $colors2->[$i]));
}
@@ -1218,7 +1220,7 @@ sub pathGraduate {
} elsif ($type eq 'transversal') {
my ($c1, $c2) = @{$style->{'-colors'}};
my @colors = ($c1, $c2);
- for ($i = 0; $i < $numcolors; $i++) {
+ for (my $i = 0; $i < $numcolors; $i++) {
push(@colors, ($c1, $c2));
}
@@ -1233,7 +1235,6 @@ sub pathGraduate {
sub createGraduate {
my ($widget, $totalsteps, $refcolors, $repeat) = @_;
my @colors;
- my $i = 0;
$repeat = 1 if (!$repeat);
my $numgraduates = scalar @{$refcolors} - 1;
@@ -1244,19 +1245,19 @@ sub createGraduate {
}
my $steps = ($numgraduates > 1) ? $totalsteps/($numgraduates -1) : $totalsteps;
- my ($c, $k);
- for ($c = 0; $c < $numgraduates; $c++) {
+
+ for (my $c = 0; $c < $numgraduates; $c++) {
my ($c1, $c2) = ($refcolors->[$c], $refcolors->[$c+1]);
- for ($i = 0 ; $i < $steps ; $i++) {
+ for (my $i = 0 ; $i < $steps ; $i++) {
my $color = computeColor($widget, $c1, $c2, $i/($steps-1));
- for ($k = 0; $k < $repeat; $k++) {
+ for (my $k = 0; $k < $repeat; $k++) {
push (@colors, $color);
}
}
if ($c < $numgraduates - 1) {
- for ($k = 0; $k < $repeat; $k++) {
+ for (my $k = 0; $k < $repeat; $k++) {
pop @colors;
}
}