Painter

Graphic context.

Modulerequire("yue.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.

setblendmode(mode)

Set how sample values are composited.

On Windows only "normal" and "copy" are supported.

Parameters

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