Painter
Graphic context.
Module | require("gui") |
Type | Class |
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
PointF
point
lineTo(point)
Connect the last point in current path to point
with a straight line.
Parameters
PointF
point
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
PointF
point - Arc's center.Number
radius - Arc's radius.Number
sa - The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians.Number
ea - The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians.
rect(rect)
Add rectangle to current path.
Parameters
RectF
rect
clip()
Add current path to clip area by intersection.
clipRect(rect)
Add rect
to clip area by intersection.
Parameters
RectF
rect
translate(offset)
Add translate transformation which moves the origin by offset
.
Parameters
Vector2dF
offset
rotate(angle)
Add rotation transformation.
Parameters
Number
angle - The angle to rotate clockwise in radians.
scale(scale)
Add scaling transformation to the painter.
Parameters
Vector2dF
scale
setColor(color)
Set stroke color and fill color to color
.
Parameters
Color
color
setStrokeColor(color)
Set the color used for shapes' outlines.
Parameters
Color
color
setFillColor(color)
Set the color used when filling shapes.
Parameters
Color
color
setLineWidth(width)
Set the width of lines.
Parameters
Number
width
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
RectF
rect
fillRect(rect)
Draw a filled rectangle.
Parameters
RectF
rect
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
AttributedText
textRectF
rect
drawText(text, rect, attributes)
Draw text
with attributes
bounded by rect
.
Parameters
String
textRectF
rectTextAttributes
attributes