GD::Arrow - draw arrows using GD


NAME

GD::Arrow - draw arrows using GD


SYNOPSIS

  use GD;
  use GD::Arrow;
  my $width = 8;
  my ($x1, $y1) = (100, 10);
  my ($x2, $y2) = (100, 190);
  my ($x3, $y3) = (10, 30);
  my ($x4, $y4) = (190, 75);
  my $arrow = GD::Arrow::Full->new( 
                  -X1    => $x1, 
                  -Y1    => $y1, 
                  -X2    => $x2, 
                  -Y2    => $y2, 
                  -WIDTH => $width,
              );
  my $image = GD::Image->new(200, 200);
  my $white = $image->colorAllocate(255, 255, 255);
  my $black = $image->colorAllocate(0, 0, 0);
  my $blue = $image->colorAllocate(0, 0, 255);
  my $yellow = $image->colorAllocate(255, 255, 0);
  $image->transparent($white);
  $image->filledPolygon($arrow,$blue);
  $image->polygon($arrow,$black);
  my $half_arrow_1 = GD::Arrow::LeftHalf->new( 
                         -X1    => $x3, 
                         -Y1    => $y3, 
                         -X2    => $x4, 
                         -Y2    => $y4, 
                         -WIDTH => $width,
                     );
  my $half_arrow_2 = GD::Arrow::LeftHalf->new( 
                         -X1    => $x4, 
                         -Y1    => $y4, 
                         -X2    => $x3, 
                         -Y2    => $y3, 
                         -WIDTH => $width 
                     );
  $image->filledPolygon($half_arrow_1,$blue);
  $image->polygon($half_arrow_1,$black);
  $image->filledPolygon($half_arrow_2,$yellow);
  $image->polygon($half_arrow_2,$black);
  open IMAGE, "> image.png" or die $!;
  binmode(IMAGE, ":raw");
  print IMAGE $image->png;
  close IMAGE;
  exit(0);


DESCRIPTION

This is a subclass of GD::Polygon used to draw an arrow between two vertices.

GD::Arrow::Full draws a full arrow between two verticies.

                                  |\
           +----------------------+ \
  (X2, Y2) *                         * (X1, Y1)
           +----------------------+ /
                                  |/

GD::Arrow::RightHalf draws a half arrow between two verticies.

  (X2, Y2) *-------------------------* (X1, Y1)
           +----------------------+ /
                                  |/

GD::Arrow::LeftHalf draws a half arrow between two verticies.

                                  |\
           +----------------------+ \
  (X2, Y2) *-------------------------* (X1, Y1)


SEE ALSO

GD::Polygon


CREDITS

The equations used to determine the critical verticies to represent a GD::Arrow was based on Hideki Ono's makefeedmap software. Makefeedmap can be found at http://www.ono.org/software/makefeedmap/.


AUTHOR

Todd Caine, <todd@pobox.com>


COPYRIGHT AND LICENSE

Copyright 2004 by Todd Caine

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.