Haiku API Bindings
Shape
Not logged in

Documentation | InterfaceKit | Shape

SYNOPSIS

Perl

use HaikuR1::Shape;

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

Python

from HaikuR1.InterfaceKit import Shape

shape = Shape()
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

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

Python

Shape()
Shape(other)
Shape(archive)

copy

Copies the contents of another object into this object.

Perl

$rect->copy($copy_from);

Python

rect.copy(copy_from)

AddShape

Adds another Shape to this Shape.

Perl

$shape->AddShape($other);

Python

shape.AddShape(other)

ArcTo

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

Perl

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

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

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

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

$shape->Bounds();

Python

shape.Bounds()

Clear

Empties the shape.

Perl

$shape->Clear();

Python

shape.Clear()

Close

Closes the shape.

Perl

$shape->Close();

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

$shape->CurrentPosition();

Python

shape.CurrentPosition()

LineTo

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

Perl

$shape->LineTo($linePoint);

Python

shape.LineTo(linePoint)

MoveTo

Changes the current point without drawing a line.

Perl

$shape->MoveTo($point);

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.