File GDGraph-trim_miter.diff of Package perl-GDGraph

--- GDGraph-1.43/Graph/lines.pm.orig	2003-02-10 23:12:41.000000000 +0100
+++ GDGraph-1.43/Graph/lines.pm	2005-03-03 17:49:26.955087130 +0100
@@ -20,6 +20,37 @@
 
 @GD::Graph::lines::ISA = qw( GD::Graph::axestype );
 
+my %Defaults = (
+	trim_miter	=> 1,
+);
+
+sub initialise()
+{
+  my $self = shift;
+  my $rc = $self->SUPER::initialise();
+  for my $k (keys %Defaults)
+    {
+      $self->{$k} = $Defaults{$k};
+    }
+  return $rc;
+}
+
+sub set
+{
+  my $self = shift;
+  my %args = @_;
+  for my $k (keys %args)
+    {
+      if ($k eq 'trim_miter')
+        {
+	  $self->{$k} = $args{$k};
+	  delete $args{$k};
+	  next;
+	}
+    }
+  return $self->SUPER::set(%args);
+}
+
 # PRIVATE
 
 sub draw_data_set
@@ -147,14 +178,33 @@
     # TODO: This loop probably should be around the datasets 
     # for nicer results
     my $i;
+    my $lw2 = int($lw/2);
     for $i (1..$lw)
     {
-        my $yslw = $ys + int($lw/2) - $i;
-        my $yelw = $ye + int($lw/2) - $i;
+        my $yslw = $ys + $lw2 - $i;
+        my $yelw = $ye + $lw2 - $i;
 
-        # Need the setstyle to reset 
-        $self->{graph}->setStyle(@pattern) if (@pattern);
-        $self->{graph}->line( $xs, $yslw, $xe, $yelw, $style );
+	if ($self->{trim_miter})
+	  {
+	    ##
+	    ## Not exactly a nice implementation of trim_miter.
+	    ## The polygon approach of lines3d is superior.
+	    ## At least it makes the lines as fat as expected
+	    ## and naturally does trimmed mitering (by wasting CPU cycles).
+	    ##
+	    for my $j (1..$lw)
+	      {
+		my $xslw = $xs + $lw2 - $j;
+		my $xelw = $xe + $lw2 - $j;
+		# Need the setstyle to reset 
+		$self->{graph}->setStyle(@pattern) if (@pattern);
+		$self->{graph}->line( $xslw, $yslw, $xelw, $yelw, $style );
+	      }
+	  }
+        else
+	  {
+	    $self->{graph}->line( $xs, $yslw, $xe, $yelw, $style );
+	  }
     }
 }
 
--- GDGraph-1.43/Graph.pm.orig	2003-07-01 07:02:10.000000000 +0200
+++ GDGraph-1.43/Graph.pm	2005-03-03 17:44:12.090345162 +0100
@@ -1290,6 +1290,14 @@
 gaps, be careful when you use this.
 Default value: 0
 
+=item trim_miter
+
+By default this is set to '1'. If line_width is large and trim_miter is '0',
+typical zig-zag data lines may appear to exaggerated, due to the width of the
+lines.  When trim_miter is set to '1', then acute-angled segments are cut back
+(with an additional small rectangle on top) to extend only half a line_width
+beyond the data points.
+
 =back
 
 =head2 Options for graphs with points
openSUSE Build Service is sponsored by