Graphics::Grid::Grob::Polygon - Polygon grob
version 0.001
use Graphics::Grid::Grob::Polygon; use Graphics::Grid::GPar; my $polygon = Graphics::Grid::Grob::Polygon->new( x => [ ( map { $_ / 10 } ( 0 .. 4 ) ), (0.5) x 5, ( map { $_ / 10 } reverse( 6 .. 10 ) ), (0.5) x 5 ], y => [ (0.5) x 5, ( map { $_ / 10 } reverse( 6 .. 10 ) ), (0.5) x 5, ( map { $_ / 10 } ( 0 .. 4 ) ), ], id => [ ( 1 .. 5 ) x 4 ], gp => Graphics::Grid::GPar->new( fill => [qw(black red green3 blue cyan)], ) ); # or user the function interface use Graphics::Grid::Functions qw(:all); my $polygon = polygon_grob(%params);
This class represents a polygon graphical object. It is a sub class of Graphics::Grid::Grob::Polyline. The difference is that when a polyline is drawn, the path is closed and fill in gp can take effect.
fill
gp
A Grahpics::Grid::Unit object specifying x-values.
Default to unit([0, 0.5, 1, 0.5], "npc").
unit([0, 0.5, 1, 0.5], "npc")
A Grahpics::Grid::Unit object specifying y-values.
Default to unit([0.5, 1, 0.5, 0], "npc").
unit([0.5, 1, 0.5, 0], "npc")
An array ref used to separate locations in x and y into multiple lines. All locations with the same id belong to the same line.
id needs to have the same length as x and y.
id
x
y
If id is not specified then all points would be regarded as being in one line.
An object of Graphics::Grid::GPar. Default is an empty gpar object.
A viewport object. When drawing a grob, if the grob has this attribute, the viewport would be temporily pushed onto the global viewport stack before drawing takes place, and be poped after drawing. If the grob does not have this attribute set, it would be drawn on the existing current viewport in the global viewport stack.
Get number of sub-elements in the grob.
Grob classes shall implement a _build_elems() method to support this attribute.
_build_elems()
This is an alias of elems.
elems
Returns info about the grob's extents (bounding box, etc) on the drawing layer, in cm.
Note that not all grob classes have got this method implemented.
For this module elems returns the number of polygons.
Graphics::Grid::Functions
Graphics::Grid::Grob
Graphics::Grid::Grob::Polyline
Stephan Loyd <sloyd@cpan.org>
This software is copyright (c) 2018-2023 by Stephan Loyd.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Graphics::Grid, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Graphics::Grid
CPAN shell
perl -MCPAN -e shell install Graphics::Grid
For more information on module installation, please visit the detailed CPAN module installation guide.