Haiku API Bindings
Point
Not logged in

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()

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)

ConstrainTo

Forces the Point within a Rect if it is not already there.

Perl

$point->ConstrainTo($rect);

Python

point.ConstrainTo(rect)

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)

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