Tickit::Rect(3pm)
π Tickit::Rect β a whole manual page, but make it a group chat
ok so this is Tickit::Rect, straight out of the Perl docs (User Contributed Perl Documentation, to be exact) β and bestie, it's a whole vibe. It's a lightweight data structure representing a rectangle. That's the whole thing. That's the girl. π
β¨ SYNOPSIS β¨
like, here's how you'd actually use her:
use Tickit::Rect;
my $rect = Tickit::Rect->new(
top => 0, left => 5, lines => 3, cols => 10
);
πΈ DESCRIPTION πΈ
So. Objects in this class represent a rectangle. How? By storing the top-left corner coordinate plus the size in lines and cols. That's it, that's the whole personality.
And no cap β this data structure is purely abstract and not tied to any particular window or coordinate system. She's not out here being a window. She's not out here being a coordinate system. She exists simply as a convenient little data store containing some genuinely useful utility methods. Main character energy, zero drama. π
π«Ά CONSTRUCTORS π«Ά
π« new
$rect = Tickit::Rect->new( %args )
Construct a brand-new rectangle of the given geometry. You give her top, left, and then either lines and cols, or bottom and right. Pick your fighter, bestie. β¨
$rect = Tickit::Rect->new( $str )
But wait β if you hand her a single string, she'll parse it in this exact form:
(left,top)..(right,bottom)
iconic parsing behaviour honestly.
π« intersect
$rect = $existing_rect->intersect( $other_rect )
If there's an intersection between the two given rectangles, she returns it. If not, she returns undef. π (the rejection is swift)
π« translate
$rect = $existing_rect->translate( $downward, $rightward )
Returns a new rectangle, same size as the given one, moved down and to the right by the given arguments β which may totally be negative, ngl. π¦
π ACCESSORS π
π« top, left, bottom, right
$top = $rect->top
$left = $rect->left
$bottom = $rect->bottom
$right = $rect->right
These return the edge boundaries of the rectangle. Four little icons, four little edges, all serving. π
π« lines, cols
$lines = $rect->lines
$cols = $rect->cols
Return the size of the rectangle. periodt. π
π« linerange
@lines = $rect->linerange( $min, $max )
A super convenient shortcut that generates the list of lines covered that are within the given bounds β and either bound may be given as undef, so don't stress about filling them both in. π
Without any bounds at all? It's equivalent to exactly this:
$rect->top .. $rect->bottom - 1
(the -1 matters, don't @ me)
π₯ METHODS π₯
π« equals
$bool = $rect->equals( $other )
$bool = ( $rect == $other )
Returns true if $other represents the same area as $rect. And the cute part β this method overloads the numerical equality operator (==), so you can literally just go $rect == $other. obsessed. π
π« contains
$bool = $rect->contains( $other )
Returns true if $other is entirely contained within the bounds of $rect. Fully. Not partially. Entirely. π
π« intersects
$bool = $rect->intersects( $other )
Returns true if $other and $rect intersect at all β even if they barely overlap. Even the tiniest touch counts. π
π« add
@r = $rect->add( $other )
Returns a list of the non-overlapping regions covered by either $rect or $other.
In the trivial case where the two given rectangles don't touch, the result is simply a list of the two initial rectangles β easy. Otherwise you get a list of newly-constructed rectangles covering the same area as the original two. That list will contain anywhere between 1 and 3 rectangles. Slay, but with a range. β
π« subtract
@r = $rect->subtract( $other )
Returns a list of the non-overlapping regions covered by $rect but not by $other. Setting boundaries, honestly.
Trivial cases first, because order matters:
- If
$othercompletely covers$rect, you get the empty list. nothing left, she's gone π - If
$otherand$rectdon't intersect at all, you get a list containing$rect. untouched, unbothered β¨ - Otherwise you get a list of newly-constructed rectangles covering the required area β and this list will contain anywhere between 1 and 4 rectangles. π§
π AUTHOR π
Paul Evans <leonerd@leonerd.org.uk> β the icon, the legend, the whole reason this page exists. π
and that's the whole page, bestie β no notes, no skipped options, every single detail accounted for π
cute lil sign-off: this one's from perl v5.42.3, dated 2026-08-19, and it lives in the User Contributed Perl Documentation section (man page Tickit::Rect(3pm)) β see you in the next man page, love u π«Άβ¨
π¦ where this page comes from
- ubuntu stonking: libtickit-perl 0.73-1build5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms