Graphics::Grid::Grob::Rect - Rectangular grob
version 0.001
use Graphics::Grid::Grob::Rect; use Graphics::Grid::GPar; my $rect = Graphics::Grid::Grob::Rect->new( x => 0.5, y => 0.5, width => 1, height => 1, just => "centre", gp => Graphics::Grid::GPar->new()); # or use the function interface use Graphics::Grid::Functions qw(:all); my $rect = rect_grob(%params);
This class represents a rectangular graphical object.
A Grahpics::Grid::Unit object specifying x-location.
Default to unit(0.5, "npc").
unit(0.5, "npc")
A Grahpics::Grid::Unit object specifying y-location.
The reference point is the left-bottom of parent viewport.
A Grahpics::Grid::Unit object specifying width.
Default to unit(1, "npc").
unit(1, "npc")
Similar to the width attribute except that it is for height.
width
The justification of the object, which consumes this role, relative to its (x, y) location.
The value is an arrayref in the form of [$hjust, $vjust], where $hjust and $vjust are two numbers for horizontal and vertical justification respectively. Each number is usually from 0 to 1, but can also beyond hat range. 0 means left alignment and 1 means right alighment.
[$hjust, $vjust]
Default is [0.5, 0.5], which means the object's center is aligned to its (x, y) position.
[0.5, 0.5]
For example, for a rectangle which has $width and $height, and positioned at ($x, $y), the position of its left-bottom corner can be calculated in this way,
$left = $x - $hjust * $width; $bottom = $y - $vjust * $height;
This attribute also supports some string values. They map to numeric values like below.
string numeric --------------------------- ------------ left [ 0, 0.5 ] top [ 0.5, 1 ] right [ 1, 0.5 ] bottom [ 0.5, 0 ] center | centre [ 0.5, 0.5 ] bottom_left | left_bottom [ 0, 0 ] top_left | left_top [ 0, 1 ] bottom_right | right_bottom [ 1, 0 ] top_right | right_top [ 1, 1 ]
A reader accessor for the horizontal justification.
A reader accessor for vertical justification.
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 rectangles.
Graphics::Grid::Functions
Graphics::Grid::Grob
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.