GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
GD::Arrow(3) User Contributed Perl Documentation GD::Arrow(3)

GD::Arrow - draw arrows using GD

  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);

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)

GD::Polygon

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/.

Todd Caine, <todd@pobox.com>

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.

2004-10-25 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.