Painter

Graphic context.

Modulerequire("gui")
TypeClass

The Painter class can not be created by user, its instance can only be recevied in drawing events or via the Canvas class.

Methods

save()

Save the entire state of the painter.

restore()

Restore the most recently saved state.

beginPath()

Create a new path.

closePath()

Close current path and move current point to the start of current path.

A straight line will be drew from current point to the start.

moveTo(point)

Move current point to point.

Parameters

lineTo(point)

Connect the last point in current path to point with a straight line.

Parameters

bezierCurveTo(cp1, cp2, ep)

Add a cubic Bézier curve to current path.

The first two points are control points and the third one is the end point. The starting point is the last point in the current path.

Parameters

arc(point, radius, sa, ea)

Add an arc to the path which is centered at point with radius starting at sa angle and ending at ea angle going in clockwise direction.

Parameters

rect(rect)

Add rectangle to current path.

Parameters

clip()

Add current path to clip area by intersection.

clipRect(rect)

Add rect to clip area by intersection.

Parameters

translate(offset)

Add translate transformation which moves the origin by offset.

Parameters

rotate(angle)

Add rotation transformation.

Parameters

scale(scale)

Add scaling transformation to the painter.

Parameters

setColor(color)

Set stroke color and fill color to color.

Parameters

setStrokeColor(color)

Set the color used for shapes' outlines.

Parameters

setFillColor(color)

Set the color used when filling shapes.

Parameters

setLineWidth(width)

Set the width of lines.

Parameters

stroke()

Draw current path by stroking its outline.

fill()

Draw a solid shape by filling current path's content area.

clear()

Fill the whole area with transparent color.

strokeRect(rect)

Draw a rectangular outline.

Parameters

fillRect(rect)

Draw a filled rectangle.

Parameters

drawImage(image, rect)

Draw scaled image to fit rect.

Parameters

drawImageFromRect(image, src, dest)

Draw the specified portion of image at src to fit rect.

Parameters

drawCanvas(canvas, rect)

Draw scaled canvas to fit rect.

Parameters

drawCanvasFromRect(canvas, src, dest)

Draw the specified portion of canvas at src to fit rect.

Parameters

drawAttributedText(text, rect)

Draw text bounded by rect.

Parameters

drawText(text, rect, attributes)

Draw text with attributes bounded by rect.

Parameters