From 7422650ed8d423c152e0438627c15c96977982b2 Mon Sep 17 00:00:00 2001 From: pmichaud Date: Thu, 21 May 2009 07:18:44 +0000 Subject: [PATCH] From Patrick Michaud: This one makes it so bars and columns use the fill styles instead of the flat colors. It also improves the light color in the ocean style, and adds an ocean_flat style. --- Graph.pm | 30 +++++++++++++++++++++++------- lib/Imager/Graph/Horizontal.pm | 8 ++++---- lib/Imager/Graph/Vertical.pm | 15 ++++++++------- 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/Graph.pm b/Graph.pm index a9aaec2..f1f5459 100644 --- a/Graph.pm +++ b/Graph.pm @@ -1438,49 +1438,49 @@ $styles{'ocean'} = { xa_ratio => 0, ya_ratio=>0, xb_ratio=>1.0, yb_ratio=>1.0, segments => Imager::Fountain->simple( positions=>[0, 1], - colors=>[ NC('FFFFFF'), NC('E6E2AF') ]), + colors=>[ NC('EFEDCF'), NC('E6E2AF') ]), }, { fountain =>'linear', xa_ratio => 0, ya_ratio=>0, xb_ratio=>1.0, yb_ratio=>1.0, segments => Imager::Fountain->simple( positions=>[0, 1], - colors=>[ NC('FFFFFF'), NC('A7A37E') ]), + colors=>[ NC('DCD7AB'), NC('A7A37E') ]), }, { fountain =>'linear', xa_ratio => 0, ya_ratio=>0, xb_ratio=>1.0, yb_ratio=>1.0, segments => Imager::Fountain->simple( positions=>[0, 1], - colors=>[ NC('FFFFFF'), NC('80B4A2') ]), + colors=>[ NC('B2E5D4'), NC('80B4A2') ]), }, { fountain =>'linear', xa_ratio => 0, ya_ratio=>0, xb_ratio=>1.0, yb_ratio=>1.0, segments => Imager::Fountain->simple( positions=>[0, 1], - colors=>[ NC('FFFFFF'), NC('046380') ]), + colors=>[ NC('7aaab9'), NC('046380') ]), }, { fountain =>'linear', xa_ratio => 0, ya_ratio=>0, xb_ratio=>1.0, yb_ratio=>1.0, segments => Imager::Fountain->simple( positions=>[0, 1], - colors=>[ NC('FFFFFF'), NC('877EA7') ]), + colors=>[ NC('c3b8e9'), NC('877EA7') ]), }, { fountain =>'linear', xa_ratio => 0, ya_ratio=>0, xb_ratio=>1.0, yb_ratio=>1.0, segments => Imager::Fountain->simple( positions=>[0, 1], - colors=>[ NC('FFFFFF'), NC('67A35E') ]), + colors=>[ NC('A3DF9A'), NC('67A35E') ]), }, { fountain =>'linear', xa_ratio => 0, ya_ratio=>0, xb_ratio=>1.0, yb_ratio=>1.0, segments => Imager::Fountain->simple( positions=>[0, 1], - colors=>[ NC('FFFFFF'), NC('B4726F') ]), + colors=>[ NC('E19C98'), NC('B4726F') ]), }, ], colors => [ @@ -1493,6 +1493,22 @@ $styles{'ocean'} = { }; +$styles{'ocean_flat'} = { + fills=> + [ + qw(E6E2AF A7A37E 80B4A2 046380 877EA7 67A35E B4726F) + ], + colors => [ + qw(E6E2AF A7A37E 80B4A2 046380 877EA7 67A35E B4726F) + ], + fg=>'000000', + negative_bg=>'EEEEEE', + bg=>'FFFFFF', + features=>{ dropshadow=>1 }, + +}; + + =item $self->_style_setup(\%opts) Uses the values from %opts to build a customized hash describing the diff --git a/lib/Imager/Graph/Horizontal.pm b/lib/Imager/Graph/Horizontal.pm index d083fbe..f143d01 100644 --- a/lib/Imager/Graph/Horizontal.pm +++ b/lib/Imager/Graph/Horizontal.pm @@ -498,7 +498,6 @@ sub _draw_bars { my $series = $col_series->[$series_pos]; my @data = @{$series->{'data'}}; my $data_size = scalar @data; - my $color = $self->_data_color($series_counter); for (my $i = 0; $i < $data_size; $i++) { my $y1 = int($bottom + $bar_height * (scalar @$col_series * $i + $series_pos)) + scalar @$col_series * $i + $series_pos + ($column_padding / 2); @@ -509,9 +508,9 @@ sub _draw_bars { my $color = $self->_data_color($series_counter); - # my @fill = $self->_data_fill($series_counter, [$x1, $y1, $x2, $zero_position]); if ($data[$i] > 0) { - $img->box(xmax => $x1, xmin => $zero_position+1, ymin => $y1, ymax => $y2, color => $color, filled => 1); + my @fill = $self->_data_fill($series_counter, [$zero_position+1, $y1, $x1, $y2]); + $img->box(xmax => $x1, xmin => $zero_position+1, ymin => $y1, ymax => $y2, @fill); if ($style->{'features'}{'outline'}) { $img->box(xmax => $x1, xmin => $zero_position, ymin => $y1, ymax => $y2, color => $outline_color); } @@ -519,7 +518,8 @@ sub _draw_bars { elsif ($data[$i] == 0) { } else { - $img->box(xmax => $zero_position , xmin => $x1, ymin => $y1, ymax => $y2, color => $color, filled => 1); + my @fill = $self->_data_fill($series_counter, [$x1, $y1, $zero_position, $y2]); + $img->box(xmax => $zero_position , xmin => $x1, ymin => $y1, ymax => $y2, @fill); if ($style->{'features'}{'outline'}) { $img->box(xmax => $zero_position, xmin => $x1, ymin => $y1, ymax => $y2, color => $outline_color); } diff --git a/lib/Imager/Graph/Vertical.pm b/lib/Imager/Graph/Vertical.pm index b152d75..2dcf2d1 100644 --- a/lib/Imager/Graph/Vertical.pm +++ b/lib/Imager/Graph/Vertical.pm @@ -666,7 +666,6 @@ sub _draw_columns { my $series = $col_series->[$series_pos]; my @data = @{$series->{'data'}}; my $data_size = scalar @data; - my $color = $self->_data_color($series_counter); for (my $i = 0; $i < $data_size; $i++) { my $x1 = int($left + $bar_width * (scalar @$col_series * $i + $series_pos)) + scalar @$col_series * $i + $series_pos + ($column_padding / 2); if ($has_stacked_columns) { @@ -678,15 +677,16 @@ sub _draw_columns { my $color = $self->_data_color($series_counter); - # my @fill = $self->_data_fill($series_counter, [$x1, $y1, $x2, $zero_position]); if ($data[$i] > 0) { - $img->box(xmin => $x1, xmax => $x2, ymin => $y1, ymax => $zero_position-1, color => $color, filled => 1); + my @fill = $self->_data_fill($series_counter, [$x1, $y1, $x2, $zero_position-1]); + $img->box(xmin => $x1, xmax => $x2, ymin => $y1, ymax => $zero_position-1, @fill); if ($style->{'features'}{'outline'}) { $img->box(xmin => $x1, xmax => $x2, ymin => $y1, ymax => $zero_position, color => $outline_color); } } else { - $img->box(xmin => $x1, xmax => $x2, ymin => $zero_position+1, ymax => $y1, color => $color, filled => 1); + my @fill = $self->_data_fill($series_counter, [$x1, $zero_position+1, $x2, $y1]); + $img->box(xmin => $x1, xmax => $x2, ymin => $zero_position+1, ymax => $y1, @fill); if ($style->{'features'}{'outline'}) { $img->box(xmin => $x1, xmax => $x2, ymin => $zero_position+1, ymax => $y1+1, color => $outline_color); } @@ -746,7 +746,6 @@ sub _draw_stacked_columns { foreach my $series (@$col_series) { my @data = @{$series->{'data'}}; my $data_size = scalar @data; - my $color = $self->_data_color($series_counter); for (my $i = 0; $i < $data_size; $i++) { my $x1 = int($left + $bar_width * ($column_series * $i)) + $column_series * $i + ($column_padding / 2); my $x2 = $x1 + $bar_width - $column_padding; @@ -754,13 +753,15 @@ sub _draw_stacked_columns { my $y1 = int($bottom + ($value_range - $data[$i] + $min_value)/$value_range * $graph_height); if ($data[$i] > 0) { - $img->box(xmin => $x1, xmax => $x2, ymin => $y1, ymax => $zero_position-1, color => $color, filled => 1); + my @fill = $self->_data_fill($series_counter, [$x1, $y1, $x2, $zero_position-1]); + $img->box(xmin => $x1, xmax => $x2, ymin => $y1, ymax => $zero_position-1, @fill); if ($style->{'features'}{'outline'}) { $img->box(xmin => $x1, xmax => $x2, ymin => $y1, ymax => $zero_position, color => $outline_color); } } else { - $img->box(xmin => $x1, xmax => $x2, ymin => $zero_position+1, ymax => $y1, color => $color, filled => 1); + my @fill = $self->_data_fill($series_counter, [$x1, $zero_position+1, $x2, $y1]); + $img->box(xmin => $x1, xmax => $x2, ymin => $zero_position+1, ymax => $y1, @fill); if ($style->{'features'}{'outline'}) { $img->box(xmin => $x1, xmax => $x2, ymin => $zero_position+1, ymax => $y1+1, color => $outline_color); } -- 2.30.2