1pod::Prima::Region(3) User Contributed Perl Documentationpod::Prima::Region(3)
2
3
4

NAME

6       Prima::Region - generic shape for clipping and hit testing
7

SYNOPSIS

9          $empty = Prima::Region->new;
10
11          $rect  = Prima::Region->new( rect => [ 10, 10, 20, 20 ]);
12          $rect  = Prima::Region->new( box  => [ 10, 10, 10, 10 ]); # same
13
14          $poly  = Prima::Region->new( polygon => [ 0, 0, 100, 0, 100, 100 ]);
15
16          $bits  = Prima::Region->new( image => $image );
17
18          $drawable-> region( $rect );
19
20          my $rgn = $drawable->region;
21          $rgn->image->save('region.png') if $rgn;
22

DESCRIPTION

24       Prima::Region is a descendant of Prima::Component. It serves a
25       representation of a generic shape, that can be applied to a drawable,
26       and checked whether points are within its boundaries.
27

API

29       new %OPTIONS
30           Creates new region object. Without options, the region is empty.
31           Following options can be used:
32
33           rect => [ X1, Y1, X2, Y2 ]
34               Create rectangular region with inclusive-inclusive coordinates.
35
36           box => [ X, Y, WIDTH, HEIGHT ]
37               Same as "rect" but using other semantics.
38
39           polygon => \@POINTS, fillMode = 0
40               Creates a polygon shape with vertices given in @POINTS, and
41               using an optional fillMode ( see "fillMode" in Drawable ).
42
43           image => IMAGE
44               Creates a region that mirrors 1-bits in the image. If no pixels
45               are set to 1, the region will be effectively empty.
46
47       bitmap with_offset => 0, type => dbt::Bitmap
48           Paints the region on a newly created bitmap and returns it. By
49           default, region offset is not included.
50
51       box Returns (X,Y,WIDTH,HEIGHT) bounding box, that encloses smallest
52           possible rectangle, or (0,0,0,0) if the region is empty.
53
54       combine REGION, OPERATION = rgnop::Copy
55           Applies one of the following set operation to the region:
56
57           rgnop::Copy
58               Makes a copy of the REGION
59
60           rgnop::Intersect
61               The resulting region is an intersection of the two regions.
62
63           rgnop::Union
64               The resulting region is a union of the two regions.
65
66           rgnop::Xor
67               Performs XOR operation on the two regions.
68
69           rgnop::Diff
70               The resulting region is a difference of the two regions.
71
72       dup Creates a duplicate region object
73
74       get_boxes
75           Returns a "Prima::array" object filled with 4-integer tuples, where
76           each is a box defined as (x,y,width,height).
77
78       get_handle
79           Returns a system handle for the region
80
81       equals REGION
82           Returns true if the regions are equal, false otherwise.
83
84       image with_offset => 0, type => dbt::Bitmap
85           Paints the region on a newly created image and returns it. By
86           default, region offset is not included.
87
88       is_empty
89           Returns true if the region is empty, false otherwise.
90
91       offset DX, DY
92           Shifts the region vertically and/or horizontally
93
94       point_inside X, Y
95           Returns true if the (X,Y) point is inside the region
96
97       rect_inside X1,Y1,X2,Y2
98           Checks whether a rectangle given by inclusive-inclusive coordinates
99           is inside, outside, or partially covered by the region. Return
100           values are:
101
102              rgn::Inside
103              rgn::Outside
104              rgn::Partially
105
106           where "rgn::Outside" has value of 0.
107

AUTHOR

109       Dmitry Karasik, <dmitry@karasik.eu.org>.
110

SEE ALSO

112       Prima, Prima::Drawable, Prima::Drawable::Path
113
114
115
116perl v5.36.0                      2023-03-20             pod::Prima::Region(3)
Impressum