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 $other completely covers $rect, you get the empty list. nothing left, she's gone πŸ’€
  • If $other and $rect don'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