Haiku API Bindings
Shape
Not logged in

Documentation | InterfaceKit | Shape

SYNOPSIS

Perl

Python

use HaikuR1::Shape;

my $shape = HaikuR1::Shape->new();
$shape->LineTo($x,$y);
$view->StrokeShape($shape);

DESCRIPTION

Exposes the BShape object.

For more information on Shape, see the Be Book class description, the Be Book overview, and the Haiku Book class description.

METHODS

Constructor

Creates a Shape.

Perl

Python

HaikuR1::Shape->new();
HaikuR1::Shape->new($other);
HaikuR1::Shape->new($archive);

copy

Copies the contents of another object into this object.

Perl

Python

$rect->copy($copy_from);

AddShape

Adds another Shape to this Shape.

Perl

Python

$shape->AddShape($other);

ArcTo

Draw an arc from the current point to the given point, along the ellipse defined by the parameters.

Perl

Python

$shape->ArcTo(
    rx               => $rx,
    ry               => $ry,
    angle            => $angle,
    largeArc         => $largeArc,
    counterClockWise => $counterClockWise,
    point            => $point,
);

BezierTo

Draw a curve from the current point to the given endpoint, using the control points to define the curve.

Perl

Python

$shape->BezierTo($control1, $control2, $endPoint);

Bounds

Returns the smallest rectangle that contains the shape.

However, this is a simplistic calculation with two shortcomings. First, it does not take Bezier curves into account; the rectangle will contain the points used to define the curve, but the curve itself may fall outside the rectangle. Second, when an arc is added (see ArcTo), the coordinate pair angle,0 is stored internally with the points, and the Bounds calculation does not take this into account, treating it the same as any other point; this may cause a distorted bounds rectangle.

Perl

Python

$shape->Bounds();

Clear

Empties the shape.

Perl

Python

$shape->Clear();

Close

Closes the shape.

Perl

Python

$shape->Close();

CurrentPosition

Returns the current position of the shape; that is, the point the next line, curve, or arc will start from.

Perl

Python

$shape->CurrentPosition();

LineTo

Draws a line from the current point to the given point.

Perl

Python

$shape->LineTo($linePoint);

MoveTo

Changes the current point without drawing a line.

Perl

Python

$shape->MoveTo($point);

OPERATORS

==

Returns true if the Shape objects contain the same shape.

!=

Returns true if the Shape objects do not contain the same shape.

ARCHIVABLE INTERFACE

Shape inherits the methods and hooks of Archivable.