pod::Prima::Region(3)

πŸ“¦
version 1.74000 Β· 5 versions
, in opensuse-leap 16.0

πŸ’– NAME πŸ’–

pod::Prima::Region(3) β€” Prima::Region β€” generic shapes for clipping and hit testing, from the User Contributed Perl Documentation, bestie πŸ’…βœ¨

✨ SYNOPSIS ✨

Okay so here's the group-chat recap of how you actually use this thing 🫢:

          $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;

🌸 DESCRIPTION 🌸

Prima::Region is a descendant of the Prima::Component class, no cap. A Prima::Region object is literally a representation of a generic shape that can be applied to a drawable and checked to see whether points are within its boundaries. Iconic.

πŸ’… API πŸ’…

Here's the whole menu, bestie β€” every method, every option, every little detail πŸ’–

  • new %OPTIONS β€” Creates a new region object. If called without any options, the resulting region will be empty. The following options can be used:
    • rect => [ X1, Y1, X2, Y2 ] β€” Creates a rectangular region with inclusive-inclusive coordinates.
    • box => [ X, Y, WIDTH, HEIGHT ] β€” Same as rect but using the box semantics.
    • polygon => \@POINTS, fillMode = 0 β€” Creates a polygon shape with vertices given in @POINTS, and using the optional fillMode (see "fillMode" in Drawable).
    • image => IMAGE β€” 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.
  • bitmap with_offset => 0, type => dbt::Bitmap β€” Paints the region on a newly created bitmap and returns it. By default, the region offset is not included.
  • box β€” Returns the (X,Y,WIDTH,HEIGHT) bounding box that encloses the smallest possible rectangle, or (0,0,0,0) if the region is empty.
  • combine REGION, OPERATION = rgnop::Copy β€” Applies one of the following set operations to the region:
    • rgnop::Copy β€” Makes a copy of the REGION.
    • rgnop::Intersect β€” The resulting region is an intersection of the two regions.
    • rgnop::Union β€” The resulting region is a union of the two regions.
    • rgnop::Xor β€” Performs XOR operation on the two regions.
    • rgnop::Diff β€” The resulting region is a difference between the two regions.
  • dup β€” Creates a duplicate region object.
  • get_boxes β€” Returns a Prima::array object filled with 4-integer tuples, where each is a box defined as a (x,y,width,height) tuple.
  • get_handle β€” Returns the system handle for the region.
  • equals REGION β€” Returns true if the regions are equal, false otherwise.
  • image with_offset => 0, type => dbt::Bitmap β€” Paints the region on a newly created image and returns it. By default, the region offset is not included.
  • is_empty β€” Returns true if the region is empty, false otherwise.
  • offset DX, DY β€” Shifts the region vertically and/or horizontally.
  • point_inside X, Y β€” Returns true if the (X,Y) point is inside the region.
  • rect_inside X1,Y1,X2,Y2 β€” 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:
    • rgn::Inside
    • rgn::Outside
    • rgn::Partially

where the rgn::Outside constant has the value of 0.

🫢 AUTHOR 🫢

Dmitry Karasik, <dmitry@karasik.eu.org>. β€” author credit, slay πŸ’–

πŸ¦‹ SEE ALSO πŸ¦‹

Go check out Prima, Prima::Drawable, and Prima::Drawable::Path β€” bestie homework, iykyk πŸ¦‹βœ¨


That's the whole thing, bestie! The source/version footer says perl v5.42.0, dated 2024-08-20, and the page is pod::Prima::Region(3) β€” now go make some iconic regions πŸ’…πŸ’–

πŸ“¦ where this page comes from