Class Painter
Painter draws anti-aliased 2D vector shapes, as well as text and images.
class Painter
Painter applies clipping and transformation to all operations. It is layered and can use various blend modes to composite layers.
Painter can save and restore it's current state (clipping, transformation,
and anti-aliasing setting) using save
method and when starting a layer.
Constructors
Name | Description |
---|---|
this
(head)
|
Properties
Type | Name | Description |
---|---|---|
bool |
antialias [get, set]
|
True whether antialiasing is enabled for subsequent drawings |
Methods
Name | Description |
---|---|
beginLayer
(saver, info)
|
Start to draw into a new layer, and compose it when saver goes out of scope.
|
clipIn
(box)
|
Intersect subsequent drawing with a region, transformed by current matrix |
clipOut
(box)
|
Remove a region, transformed by current matrix, from subsequent drawing |
drawCustomScene
(scene, size, layerInfo)
|
Render a custom scene into a texture and compose it as usual layer |
drawImage
(image, x, y, opacity)
|
Draw an image at some position with some opacity |
drawLine
(x0, y0, x1, y1, color)
|
Draw a thin 1px line between two points (including the last pixel). |
drawNinePatch
(image, srcRect, dstRect, opacity)
|
Draw a rescaled nine-patch image with some opacity |
drawText
(run, color)
|
Draw a text run at some position with some color |
fill
(path, brush, rule)
|
Fill a path using specified brush |
fillCircle
(centerX, centerY, radius, color)
|
Fill a circle |
fillRect
(x, y, width, height, color)
|
Fill a simple axis-oriented rectangle |
fillTriangle
(p0, p1, p2, color)
|
Fill a triangle. Use it if you need to draw lone solid triangles |
getLocalClipBounds
()
|
Get bounds of clip, transformed into the local coordinate system. |
paintOut
(brush)
|
Fill the layer with specified brush |
quickReject
(box)
|
Quickly (and inaccurately) determine that box is outside the clip.
|
resetMatrix
()
|
Reset canvas transformation to identity |
rotate
(degrees)
|
Rotate subsequent canvas drawings clockwise |
rotate
(degrees, cx, cy)
|
Rotate subsequent canvas drawings clockwise around a point |
save
(saver)
|
Save matrix, clip, and anti-aliasing setting into internal stack. |
scale
(factor)
|
Scale subsequent canvas drawings |
setMatrix
(m)
|
Setup canvas transformation matrix, replacing current one |
skew
(degreesX, degreesY)
|
Skew subsequent canvas drawings by the given angles |
stroke
(path, brush, pen)
|
Stroke a path using specified brush |
transform
(m)
|
Concat a matrix to the current canvas transformation |
translate
(dx, dy)
|
Translate origin of the canvas |
Note
Clipping always shrinks available drawing area.