Imager::Draw::Hexagon - Draw hexes easily using Imager
version 0.0102
use Imager::Draw::Hexagon; my $hex = Imager::Draw::Hexagon->new( image => $image, side_length => 100 ); $hex->draw(color => 'blue');
Drawing hexagons requires calculating all the points in the hex. It's harder than it sounds. I figured since I was solving it, I might as well solve it for everyone, so this module was born.
Constructor.
The Imager object to draw the hex on to. Required.
The length of each side of the hexagon in pixels. Required.
The x coordinate of the top left corner to start drawing the hex. Defaults to 0.
The y coordinate of the top left corner to start drawing the hex. Defaults to 0.
Get or set the x coordinate of the top left corner of where to start drawing the hex.
Get or set the y coordinate of the top left corner of where to start drawing the hex.
Get or set the Imager object.
Get or set the length, in pixels, of each side of the hex.
Hexes are essentially a square with a series of right trangles drawn around them. This is the short leg of that triangle or half the value of the side length.
Hexes are essentially a square with a series of right trangles drawn around them. This is the long leg of that triangle or the side length multiplied by 0.866 (sin(60)).
Returns an array ref of coordinent pairs if the hex is to be drawn with a flat top (east-west).
Returns an array ref of coordinent pairs if the hex is to be drawn with a peaked top (north-south).
Call this to draw an outline of a hex on the image. It accepts all the same parameters as "polyline" in Imager::Draw, plus:
Defaults to ew. Options are ew and ns.
ew
ns
Call this to draw a filled hex on the image. It accepts all the same parameters as "polygon" in Imager::Draw, plus:
None that I can think of at this time.
Moo Imager
http://github.com/rizen/Imager-Draw-Hexagon
http://github.com/rizen/Imager-Draw-Hexagon/issues
Imager::Draw::Hexagon is Copyright 2014 Plain Black Corporation (http://www.plainblack.com) and is licensed under the same terms as Perl itself.
To install Imager::Draw::Hexagon, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Imager::Draw::Hexagon
CPAN shell
perl -MCPAN -e shell install Imager::Draw::Hexagon
For more information on module installation, please visit the detailed CPAN module installation guide.