Haiku API Bindings
PictureCallbacks
Not logged in

Documentation | InterfaceKit | PictureCallbacks

SYNOPSIS

Perl

# define MyPlayer class

my $player = MyPlayer->new();

$picture->Play($player);

Python

# define MyPlayer class

player = MyPlayer->new()

picture.Play(player)

DESCRIPTION

Picture.Play allows you to translate a Picture into some other format; for example, Haiku's app server translate the stored instructions into pixels on the screen. However, you could also use it to translate a Picture into an SVG image, or any other image format.

The C++ version of Play takes a data pointer and an array of callback functions; the bindings version takes an object and the glue code calls methods on that object.

A callback object must provide the methods described below. As a convenience, a base object is provided, allowing you to inherit empty versions of methods you don't want to support.

Perl

package MyPicturePlayer;
our @ISA = qw(HaikuR1::PictureCallbacks);

sub new {
    my ($class, $data) = @_;
    my $self = bless { data => $data }, $class;
    return self;
}

# override supported methods here

Python

from HaikuR1.InterfaceKit import PictureCallbacks
class MyPicturePlayer(PictureCallbacks):

def __new__(self, data):
    self.data = data
    return self

# override supported methods here

Inheriting from the base object is not required, but in that case you must supply all the methods listed below or you program will crash if the Picture contains an operation you do not support.

METHODS

Arcs

StrokeArc

FillArc

Perl

StrokeArc($center, $radii, $startTheta, $arcTheta);
FillArc($center, $radii, $startTheta, $arcTheta);

Python

StrokeArc(center, radii, startTheta, arcTheta)
FillArc(center, radii, startTheta, arcTheta)

Bezier curves

StrokeBezier

FillBezier

Perl

StrokeBezier($control);
FillBezier($control);

Python

StrokeBezier(control)
FillBezier(control)

Clipping

SetClippingRects

ClipToPicture

Perl

SetClippingRects($rects);
ClipToPicture($picture, $origin, $clipToInverse);

Python

SetClippingRects(rects)
ClipToPicture(picture, origin, clipToInverse)

Colors

SetForeColor

SetBackColor

Perl

SetForeColor($color);
SetBackColor($color);

Python

SetForeColor(color)
SetBackColor(color)

Drawing modes

SetDrawingMode

SetLineMode

SetBlendingMode

Perl

SetDrawingMode($mode);
SetLineMode($capMode, $joinMode, $miterLimit);
SetBlendingMode($alphaSrcMode, $alphaFncMode);

Python

SetDrawingMode(mode)
SetLineMode(capMode, joinMode, miterLimit)
SetBlendingMode(alphaSrcMode, alphaFncMode)

Ellipses

StrokeEllipse

FillEllipse

Perl

StrokeEllipse($center, $radii);
FillEllipse($center, $radii);

Python

StrokeEllipse(center, radii)
FillEllipse(center, radii)

Fonts

SetFontFamily

SetFontStyle

SetFontSpacing

SetFontSize

SetFontRotate

SetFontEncoding

SetFontFlags

SetFontShear

SetFontFace

Perl

SetFontFamily($family);
SetFontStyle($style);
SetFontSpacing($spacing);
SetFontSize($size);
SetFontRotate($rotation);
SetFontEncoding($encoding);
SetFontFlags($flags);
SetFontShear($shear);
SetFontFace($face);

Python

SetFontFamily(family)
SetFontStyle(style)
SetFontSpacing(spacing)
SetFontSize(size)
SetFontRotate(rotation)
SetFontEncoding(encoding)
SetFontFlags(flags)
SetFontShear(shear)
SetFontFace(face)

Lines

StrokeLine

Perl

StrokeLine($start, $end);

Python

StrokeLine(start, end)

Origin

SetOrigin

Perl

SetOrigin($point);

Python

SetOrigin(point)

Pens

MovePenBy

SetPenLocation

SetPenSize

SetStipplePattern

Perl

MovePenBy($delta);
SetPenLocation($point);
SetPenSize($size);
SetStipplePattern($pattern);

Python

MovePenBy(delta)
SetPenLocation(point)
SetPenSize(size)
SetStipplePattern(pattern)

Pictures

DrawPicture

Perl

DrawPicture($where, $picture);

Python

DrawPicture(where, picture)

Pixels

DrawPixels

Perl

DrawPixels($src, $dest, $width, $height, $bytesPerRow, $pixelFormat, $flags, $data);

Python

DrawPixels(src, dest, width, height, bytesPerRow, pixelFormat, flags, data)

Polygons

StrokePolygon

FillPolygon

Perl

StrokePolygon($points, $isClosed);
FillPolygon($points, $isClosed);

Python

StrokePolygon(points, isClosed)
FillPolygon(points, isClosed)

Called when ...

Rectangles

StrokeRect

FillRect

StrokeRoundRect

FillRoundRect

Perl

StrokeRect($rect);
FillRect($rect);
StrokeRoundRect($rect, $radii);
FillRoundRect($rect, $radii);

Python

StrokeRect(rect)
FillRect(rect)
StrokeRoundRect(rect, radii)
FillRoundRect(rect, radii)

Scale

SetScale

Perl

SetScale($scale);

Python

SetScale(scale)

Shapes

StrokeShape

FillShape

Perl

StrokeShape($shape);
FillShape($shape);

Python

StrokeShape(shape)
FillShape(shape)

Strings

DrawString

Perl

DrawString($string, $deltax, $deltay);

Python

DrawString(string, deltax, deltay)

State

PushState

PopState

EnterStateChange

ExitStateChange

EnterFontState

ExitFontState