- SEE ALSO
- COPYRIGHT AND LICENSE
Graphics::Grid::Justifiable - Role for supporting positional justifications in Graphics::Grid
This role describes something that has "justification" which defines how the object's exact position be determined and ajusted from its (x, y) attributes.
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.
[0.5, 0.5], which means the object's center is aligned to its (x, y) position.
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.
Calculate (left, bottom) position according to x, y, width and height.
Stephan Loyd <email@example.com>
This software is copyright (c) 2018 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.