Documentation | InterfaceKit | Point
SYNOPSIS
Perl
use HaikuR1::Point qw(B_ORIGIN); my $point = HaikuR1::Point->new($x, $y);
Python
from HaikuR1.InterfaceKit import Point, B_ORIGIN point = Point(x, y)
DESCRIPTION
Exposes the BPoint object.
As a convenience, wherever a method expects a Point as input, you may pass a two-item native list or native map instead. In addition, you may treat a Point object like a native list.
For more information on Point, see the Be Book class description, the Be Book overview, and the Haiku Book class description.
Perl
# input converters
$message->AddPoint("point", [$x,$y]);
$message->AddPoint("point", {
x => $x,
y => $y
});
# list accessors
$point->[0] = $x;
$point->[1] = $y;
Python
# input converters
message.AddPoint("point", [x,y])
message.AddPoint("point", {
x = x,
y = y
})
# list accessors
point[0] = x
point[1] = y
PROPERTIES
x
x coordinate
y
y coordinate
METHODS
Constructor
Creates a Point.
Perl
HaikuR1::Point->new($x, $y); HaikuR1::Point->new($copy_from); HaikuR1::Point->new();
Python
Point(x, y) Point(copy_from) Point()
x,yOptional floating point numbers, the coordinates of the point.
copy_fromOptional, a Point to copy. (Substitution of a native list is not implemented here.)
If neither coordinates nor a Point to copy is provided, the Point object will
default to 0, 0.
copy
Copies the contents of another object into this object.
Perl
$point->copy($copy_from);
Python
point.copy(copy_from)
copy_fromA Point to copy.
ConstrainTo
Forces the Point within a Rect if it is not already there.
Perl
$point->ConstrainTo($rect);
Python
point.ConstrainTo(rect)
rectThe Rect to constrain the Point to.
PrintToStream
Prints the contents to standard out as BRect(left, top, right, bottom)
Perl
$point->PrintToStream();
Python
point.PrintToStream()
Set
Changes a Point's coordinates.
Perl
$point->Set($x, $y);
Python
point.Set(x, y)
x,yFloating point numbers, the new coordinates.
OPERATORS
==
Returns true if the Point objects refer to the same coordinates.
!=
Returns true if the Point objects do not refer to the same coordinates.
+
Results in a point in which the x coordinate is the sum of the x
coordinates of the two operands, and the y coordinate is the sum of the y
coordinates of the two operands.
-
Results in a point in which the x coordinate is the difference of the x
coordinates of the two operands, and the y coordinate is the difference of
the y coordinates of the two operands.
+=
p1 += p2 is shorthand for p1 = p1 + p2.
-=
p1 -= p2 is shorthand for p1 = p1 - p2.
CONSTANTS
B_ORIGIN
Contains the value
0, 0.