/usr/share/perl5/GD/Graph/lines.pm is in libgd-graph-perl 1.44-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | #==========================================================================
# Copyright (c) 1995-1998 Martien Verbruggen
#--------------------------------------------------------------------------
#
# Name:
# GD::Graph::lines.pm
#
# $Id: lines.pm,v 1.15 2005/12/14 04:13:00 ben Exp $
#
#==========================================================================
package GD::Graph::lines;
($GD::Graph::lines::VERSION) = '$Revision: 1.15 $' =~ /\s([\d.]+)/;
use strict;
use GD;
use GD::Graph::axestype;
@GD::Graph::lines::ISA = qw( GD::Graph::axestype );
# PRIVATE
sub draw_data_set
{
my $self = shift;
my $ds = shift;
my @values = $self->{_data}->y_values($ds) or
return $self->_set_error("Impossible illegal data set: $ds",
$self->{_data}->error);
my $dsci = $self->set_clr($self->pick_data_clr($ds) );
my $type = $self->pick_line_type($ds);
my ($xb, $yb);
if (defined $values[0])
{
if (defined($self->{x_min_value}) && defined($self->{x_max_value}))
{
($xb, $yb) =
$self->val_to_pixel($self->{_data}->get_x(0), $values[0], $ds);
}
else
{
($xb, $yb) = $self->val_to_pixel(1, $values[0], $ds);
}
}
for (my $i = 0; $i < @values; $i++)
{
if (!defined $values[$i])
{
($xb, $yb) = () if $self->{skip_undef};
next;
}
my ($xe, $ye);
if (defined($self->{x_min_value}) && defined($self->{x_max_value}))
{
($xe, $ye) = $self->val_to_pixel(
$self->{_data}->get_x($i), $values[$i], $ds);
}
else
{
($xe, $ye) = $self->val_to_pixel($i+1, $values[$i], $ds);
}
if (defined $xb)
{
$self->draw_line($xb, $yb, $xe, $ye, $type, $dsci)
if defined $dsci;
$self->{_hotspots}->[$ds]->[$i] =
['line', $xb, $yb, $xe, $ye, $self->{line_width}];
}
($xb, $yb) = ($xe, $ye);
}
return $ds;
}
sub pick_line_type
{
my $self = shift;
my $num = shift;
ref $self->{line_types} ?
$self->{line_types}[ $num % (1 + $#{$self->{line_types}}) - 1 ] :
$num % 4 ? $num % 4 : 4
}
sub draw_line # ($xs, $ys, $xe, $ye, $type, $colour_index)
{
my $self = shift;
my ($xs, $ys, $xe, $ye, $type, $clr) = @_;
my $lw = $self->{line_width};
my $lts = $self->{line_type_scale};
my $style = gdStyled;
my @pattern = ();
LINE: {
($type == 2) && do {
# dashed
for (1 .. $lts) { push @pattern, $clr }
for (1 .. $lts) { push @pattern, gdTransparent }
$self->{graph}->setStyle(@pattern);
last LINE;
};
($type == 3) && do {
# dotted,
for (1 .. 2) { push @pattern, $clr }
for (1 .. 2) { push @pattern, gdTransparent }
$self->{graph}->setStyle(@pattern);
last LINE;
};
($type == 4) && do {
# dashed and dotted
for (1 .. $lts) { push @pattern, $clr }
for (1 .. 2) { push @pattern, gdTransparent }
for (1 .. 2) { push @pattern, $clr }
for (1 .. 2) { push @pattern, gdTransparent }
$self->{graph}->setStyle(@pattern);
last LINE;
};
# default: solid
$style = $clr;
}
# Tried the line_width thing with setBrush, ugly results
# TODO: This loop probably should be around the datasets
# for nicer results
my $i;
for $i (1..$lw)
{
my $yslw = $ys + int($lw/2) - $i;
my $yelw = $ye + int($lw/2) - $i;
# Need the setstyle to reset
$self->{graph}->setStyle(@pattern) if (@pattern);
$self->{graph}->line( $xs, $yslw, $xe, $yelw, $style );
}
}
sub draw_legend_marker # (data_set_number, x, y)
{
my $self = shift;
my ($n, $x, $y) = @_;
my $ci = $self->set_clr($self->pick_data_clr($n));
return unless defined $ci;
my $type = $self->pick_line_type($n);
$y += int($self->{lg_el_height}/2);
# Joe Smith <jms@tardis.Tymnet.COM>
local($self->{line_width}) = 2; # Make these show up better
$self->draw_line(
$x, $y,
$x + $self->{legend_marker_width}, $y,
$type, $ci
);
}
"Just another true value";
|