NAME
TUI::Objects::Point - two-dimensional point value type
HIERARCHY
TPoint (value type)
used by TRect and view-related classes
SYNOPSIS
use TUI::Objects;
my $p1 = new_TPoint(10, 5);
my $p2 = new_TPoint(3, 2);
my $p3 = $p1 + $p2;
my $p4 = $p1 - $p2;
if ( $p3 == $p4 ) {
...
}
DESCRIPTION
TPoint represents a two-dimensional point with integer coordinates. It is a lightweight value type and is not derived from TObject. Instances are typically used to represent positions, sizes, or offsets within the Turbo Vision coordinate system.
The class supports arithmetic and comparison operators through Perl operator overloading, allowing points to be combined and compared naturally.
CONSTRUCTOR
new
my $point = TPoint->new(
x => $x,
y => $y
);
Creates a new point object.
- x
-
Horizontal coordinate (Int).
- y
-
Vertical coordinate (Int).
new_TPoint
my $point = new_TPoint($x, $y);
Factory-style constructor using positional arguments.
This constructor is provided for compatibility with traditional Turbo Vision construction patterns.
ATTRIBUTES
The following attributes define the coordinates of the point.
- x
-
Horizontal coordinate (Int).
- y
-
Vertical coordinate (Int).
METHODS
add
my $p = $point->add($a, $b, | $swap);
Returns the sum of two points.
add_assign
$point->add_assign($other, | $swap);
Adds another point to this point in place.
clone
my $copy = $point->clone();
Creates and returns a copy of the point.
dump
my $string = $point->dump();
Returns a string representation of the point for debugging purposes.
equal
my $bool = $point->equal($a, $b, | $swap);
Returns true if two points have equal coordinates.
not_equal
my $bool = $point->not_equal($a, $b, | $swap);
Returns true if two points differ in at least one coordinate.
subtract
my $p = $point->subtract($a, $b, | $swap);
Returns the difference between two points.
subtract_assign
$point->subtract_assign($other, | $swap);
Subtracts another point from this point in place.
OPERATOR OVERLOADING
TPoint supports arithmetic and comparison operations through Perl operator overloading. The following operators are implemented and mapped directly to their corresponding methods:
+and+=for point addition-and-=for point subtraction==and!=for equality and inequality comparison
Operator overloading allows point objects to be combined and compared using natural arithmetic expressions.
SEE ALSO
TUI::Objects::Rect, TUI::Views::View
AUTHORS
- Borland International (original Turbo Vision design)
- J. Schneider <brickpool@cpan.org> (Perl implementation and maintenance)
COPYRIGHT AND LICENSE
Copyright (c) 1990-1994, 1997 by Borland International
Copyright (c) 2021-2026 the "AUTHORS" as listed above.
This software is licensed under the MIT license (see the LICENSE file, which is part of the distribution).