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)
center
A Point, the center of the ellipse that defines the arc.
radii
A Point, the horizontal and vertical radii of the ellipses that form the rounded corners.
startTheta
,arcTheta
Floating point numbers, the span in degrees along which the arc will travel (i.e., start angle plus arc angle equals end angle)
Bezier curves
StrokeBezier
FillBezier
Perl
StrokeBezier($control); FillBezier($control);
Python
StrokeBezier(control) FillBezier(control)
control
A native list of four control Points.
Clipping
SetClippingRects
ClipToPicture
Perl
SetClippingRects($rects); ClipToPicture($picture, $origin, $clipToInverse);
Python
SetClippingRects(rects) ClipToPicture(picture, origin, clipToInverse)
rects
A native list of Rects.
picture
A Picture.
origin
A Point, where the clipping should begin.
clipToInverse
A boolean, true if the inverse should be clipped.
Colors
SetForeColor
SetBackColor
Perl
SetForeColor($color); SetBackColor($color);
Python
SetForeColor(color) SetBackColor(color)
color
An rgb_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)
mode
An integer, one of the drawing mode constants.
capMode
One of the line cap mode constants.
joinMode
One of the line join mode constants.
miterLimit
A floating point number.
alphaSrcMode
An integer, one of the source alpha constants.
alphaFncMode
An integer, one of the alpha function constants.
Ellipses
StrokeEllipse
FillEllipse
Perl
StrokeEllipse($center, $radii); FillEllipse($center, $radii);
Python
StrokeEllipse(center, radii) FillEllipse(center, radii)
center
A Point, the center of the ellipse.
radii
A Point, the horizontal and vertical radii of the ellipses that form the rounded corners.
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)
family
A string, the family name.
style
A string, the style name.
spacing
An integer, one of the font spacing constants.
size
A floating point number, the font size in points.
rotation
A floating point number, the font rotation in degrees.
encoding
An integer, one of the font encoding constants.
flags
An integer, a combination of font flags.
shear
A floating point number, the font shear in degrees; must be between 45 and 135.
face
An integer, one of the font face constants.
Lines
StrokeLine
Perl
StrokeLine($start, $end);
Python
StrokeLine(start, end)
start
,end
Points, the endpoints of the line.
Origin
SetOrigin
Perl
SetOrigin($point);
Python
SetOrigin(point)
point
A Point, the new origin.
Pens
MovePenBy
SetPenLocation
SetPenSize
SetStipplePattern
Perl
MovePenBy($delta); SetPenLocation($point); SetPenSize($size); SetStipplePattern($pattern);
Python
MovePenBy(delta) SetPenLocation(point) SetPenSize(size) SetStipplePattern(pattern)
delta
A Point, the difference in the
x
andy
coordinates.point
A Point, the new location.
size
A floating point number.
pattern
The pattern the pen will draw with.
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)
src
,dest
Rects, the source coordinates (in
data
) and the destination coordinates (in the target).width
,height
Integers, the width and height of the image in
data
.bytesPerRow
An integer, the number of bytes per row in
data
.pixelFormat
An integer, one of the color space constants.
flags
An integer combination of bitmap drawing options.
data
The raw pixel data.
Polygons
StrokePolygon
FillPolygon
Perl
StrokePolygon($points, $isClosed); FillPolygon($points, $isClosed);
Python
StrokePolygon(points, isClosed) FillPolygon(points, isClosed)
Called when ...
points
A native list of Points.
isClosed
A boolean, true if the polygon is closed (i.e., a line should be drawn from the final point back to the first point).
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)
rect
A Rect.
radii
A Point, the horizontal and vertical radii of the ellipses that form the rounded corners.
Scale
SetScale
Perl
SetScale($scale);
Python
SetScale(scale)
scale
A floating point number.
Shapes
StrokeShape
FillShape
Perl
StrokeShape($shape); FillShape($shape);
Python
StrokeShape(shape) FillShape(shape)
shape
A Shape.
Strings
DrawString
Perl
DrawString($string, $deltax, $deltay);
Python
DrawString(string, deltax, deltay)
string
The string to draw.
deltax
,deltay
Floating point numbers, the horizontal and vertical offsets.