Hello,
This is a very simple patch to add shadow to 3d pie, with
this modification, they really look in 3d (see examples).
The patch applies to the latest version.
Bye
--- GD/Graph/pie.pm.org 2010-07-17 15:33:05.000000000 +0200
+++ GD/Graph/pie.pm 2010-07-17 15:41:10.000000000 +0200
@@ -54,6 +54,24 @@
axislabelclr => 'black',
);
+# ----------------------------------------------------------
+# Sub: _darken
+#
+# Args: $r, $g, $b
+# $r, $g, $b The Red, Green, and Blue components of a color
+#
+# Description: Darkens the color by adding black
+sub _darken {
+ my( $r, $g, $b ) = @_;
+ my $p = ($r + $g + $b) / 70;
+ $p = 3 if $p < 3;
+ my $f = _max( $r / $p, _max( $g / $p, $b / $p) );
+ $r = _max( 0, int( $r - $f ) );
+ $g = _max( 0, int( $g - $f ) );
+ $b = _max( 0, int( $b - $f ) );
+ return( $r, $g, $b );
+} # end _darken
+
# PRIVATE
sub _has_default {
my $self = shift;
@@ -292,6 +310,7 @@
# different way.
if ($self->{'3d'})
{
+ my $dc_dark = $self->set_clr(_darken($self->pick_data_clr($i + 1)));
foreach my $fill ($self->_get_pie_front_coords($pa, $pb))
{
my ($fx,$fy) = @$fill;
@@ -300,7 +319,7 @@
# looking for a gap to fill
while ( $new_y > $fy ) {
if ($self->{graph}->getPixel($fx,$new_y) != $ac) {
- $self->{graph}->fillToBorder($fx, $new_y, $ac, $dc);
+ $self->{graph}->fillToBorder($fx, $new_y, $ac, $dc_dark);
last;
}
} continue { $new_y-- }