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 effecively 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 interesection 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_handle
75           Returns a system handle for the region
76
77       equals REGION
78           Returns true if the regions are equal, false otherwise.
79
80       image with_offset => 0, type => dbt::Bitmap
81           Paints the region on a newly created image and returns it. By
82           default, region offset is not included.
83
84       is_empty
85           Returns true if the region is empty, false otherwise.
86
87       offset DX, DY
88           Shifts the region vertically and/or horizontally
89
90       point_inside X, Y
91           Returns true if the (X,Y) point is inside the region
92
93       rect_inside X1,Y1,X2,Y2
94           Checks whether a rectangle given by inclusive-inclusive coordiates
95           is inside, outside, or partially covered by the region. Return
96           values are:
97
98              rgn::Inside
99              rgn::Outside
100              rgn::Partially
101
102           where "rgn::Outside" has value of 0.
103

AUTHOR

105       Dmitry Karasik, <dmitry@karasik.eu.org>.
106

SEE ALSO

108       Prima, Prima::Drawable, Prima::Drawable::Path
109
110
111
112perl v5.32.0                      2020-07-28             pod::Prima::Region(3)
Impressum