Prima::Region - generic shapes for clipping and hit testing
$empty = Prima::Region->new;
$rect = Prima::Region->new( rect => [ 10, 10, 20, 20 ]);
$rect = Prima::Region->new( box => [ 10, 10, 10, 10 ]); # same
$poly = Prima::Region->new( polygon => [ 0, 0, 100, 0, 100, 100 ]);
$bits = Prima::Region->new( image => $image );
$drawable-> region( $rect );
my $rgn = $drawable->region;
$rgn->image->save('region.png') if $rgn;
The Prima::Region class is a descendant of the Prima::Component class. A Prima::Region object is a representation of a generic shape that can be applied to a drawable and checked whether points are within its boundaries.
Creates a new region object. If called without any options then the resulting region will be empty The following options can be used:
Creates a rectangular region with inclusive-inclusive coordinates.
Same as rect but using the box semantics.
Creates a polygon shape with vertices given in @POINTS, and using the optional fillMode ( see "fillMode" in Drawable ).
Creates a region from a 1-bit image. If the image contains no pixels that are set to 1, the resulting region is created as an empty region.
Paints the region on a newly created bitmap and returns it. By default, the region offset is not included.
Returns the (X,Y,WIDTH,HEIGHT) bounding box that encloses the smallest possible rectangle, or (0,0,0,0) if the region is empty.
Applies one of the following set operations to the region:
Makes a copy of the REGION
The resulting region is an intersection of the two regions.
The resulting region is a union of the two regions.
Performs XOR operation on the two regions.
The resulting region is a difference between the two regions.
Creates a duplicate region object
Returns a Prima::array object filled with 4-integer tuples, where each is a box defined as a (x,y,width,height) tuple.
Returns the system handle for the region
Returns true if the regions are equal, false otherwise.
Paints the region on a newly created image and returns it. By default, the region offset is not included.
Returns true if the region is empty, false otherwise.
Shifts the region vertically and/or horizontally
Returns true if the (X,Y) point is inside the region
Checks whether a rectangle given by the inclusive-inclusive coordinates is inside, outside, or partially covered by the region. The return value can be one of these flags:
where the rgn::Outside constant has the value of 0.
Dmitry Karasik, <firstname.lastname@example.org>.
Prima, Prima::Drawable, Prima::Drawable::Path
To install Prima, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.