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)
centerA Point, the center of the ellipse that defines the arc.
radiiA Point, the horizontal and vertical radii of the ellipses that form the rounded corners.
startTheta,arcThetaFloating 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)
controlA native list of four control Points.
Clipping
SetClippingRects
ClipToPicture
Perl
SetClippingRects($rects); ClipToPicture($picture, $origin, $clipToInverse);
Python
SetClippingRects(rects) ClipToPicture(picture, origin, clipToInverse)
rectsA native list of Rects.
pictureA Picture.
originA Point, where the clipping should begin.
clipToInverseA boolean, true if the inverse should be clipped.
Colors
SetForeColor
SetBackColor
Perl
SetForeColor($color); SetBackColor($color);
Python
SetForeColor(color) SetBackColor(color)
colorAn 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)
modeAn integer, one of the drawing mode constants.
capModeOne of the line cap mode constants.
joinModeOne of the line join mode constants.
miterLimitA floating point number.
alphaSrcModeAn integer, one of the source alpha constants.
alphaFncModeAn integer, one of the alpha function constants.
Ellipses
StrokeEllipse
FillEllipse
Perl
StrokeEllipse($center, $radii); FillEllipse($center, $radii);
Python
StrokeEllipse(center, radii) FillEllipse(center, radii)
centerA Point, the center of the ellipse.
radiiA 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)
familyA string, the family name.
styleA string, the style name.
spacingAn integer, one of the font spacing constants.
sizeA floating point number, the font size in points.
rotationA floating point number, the font rotation in degrees.
encodingAn integer, one of the font encoding constants.
flagsAn integer, a combination of font flags.
shearA floating point number, the font shear in degrees; must be between 45 and 135.
faceAn integer, one of the font face constants.
Lines
StrokeLine
Perl
StrokeLine($start, $end);
Python
StrokeLine(start, end)
start,endPoints, the endpoints of the line.
Origin
SetOrigin
Perl
SetOrigin($point);
Python
SetOrigin(point)
pointA 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)
deltaA Point, the difference in the
xandycoordinates.pointA Point, the new location.
sizeA floating point number.
patternThe 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,destRects, the source coordinates (in
data) and the destination coordinates (in the target).width,heightIntegers, the width and height of the image in
data.bytesPerRowAn integer, the number of bytes per row in
data.pixelFormatAn integer, one of the color space constants.
flagsAn integer combination of bitmap drawing options.
dataThe raw pixel data.
Polygons
StrokePolygon
FillPolygon
Perl
StrokePolygon($points, $isClosed); FillPolygon($points, $isClosed);
Python
StrokePolygon(points, isClosed) FillPolygon(points, isClosed)
Called when ...
pointsA native list of Points.
isClosedA 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)
rectA Rect.
radiiA Point, the horizontal and vertical radii of the ellipses that form the rounded corners.
Scale
SetScale
Perl
SetScale($scale);
Python
SetScale(scale)
scaleA floating point number.
Shapes
StrokeShape
FillShape
Perl
StrokeShape($shape); FillShape($shape);
Python
StrokeShape(shape) FillShape(shape)
shapeA Shape.
Strings
DrawString
Perl
DrawString($string, $deltax, $deltay);
Python
DrawString(string, deltax, deltay)
stringThe string to draw.
deltax,deltayFloating point numbers, the horizontal and vertical offsets.