Painter
Graphic context.
Header | #include "nativeui/gfx/painter.h" |
Namespace | namespace nu |
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
void Save()
Save the entire state of the painter.
void Restore()
Restore the most recently saved state.
void SetBlendMode(BlendMode mode)
Set how sample values are composited.
On Windows only Normal
and Copy
are supported.
Parameters
BlendMode
mode
void BeginPath()
Create a new path.
void 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.
void MoveTo(const PointF& point)
Move current point to point
.
Parameters
const PointF&
point
void LineTo(const PointF& point)
Connect the last point in current path to point
with a straight line.
Parameters
const PointF&
point
void BezierCurveTo(const PointF& cp1, const PointF& cp2, const PointF& 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
const PointF&
cp1const PointF&
cp2const PointF&
ep
void Arc(const PointF& point, float radius, float sa, float 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
const PointF&
point - Arc's center.float
radius - Arc's radius.float
sa - The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians.float
ea - The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians.
void Rect(const RectF& rect)
Add rectangle to current path.
Parameters
const RectF&
rect
void Clip()
Add current path to clip area by intersection.
void ClipRect(const RectF& rect)
Add rect
to clip area by intersection.
Parameters
const RectF&
rect
void Translate(const Vector2dF& offset)
Add translate transformation which moves the origin by offset
.
Parameters
const Vector2dF&
offset
void Rotate(float angle)
Add rotation transformation.
Parameters
float
angle - The angle to rotate clockwise in radians.
void Scale(const Vector2dF& scale)
Add scaling transformation to the painter.
Parameters
const Vector2dF&
scale
void SetColor(Color color)
Set stroke color and fill color to color
.
Parameters
Color
color
void SetStrokeColor(Color color)
Set the color used for shapes' outlines.
Parameters
Color
color
void SetFillColor(Color color)
Set the color used when filling shapes.
Parameters
Color
color
void SetLineWidth(float width)
Set the width of lines.
Parameters
float
width
void Stroke()
Draw current path by stroking its outline.
void Fill()
Draw a solid shape by filling current path's content area.
void Clear()
Fill the whole area with transparent color.
void StrokeRect(const RectF& rect)
Draw a rectangular outline.
Parameters
const RectF&
rect
void FillRect(const RectF& rect)
Draw a filled rectangle.
Parameters
const RectF&
rect
void DrawImage(Image* image, const RectF& rect)
Draw scaled image
to fit rect
.
Parameters
Image*
imageconst RectF&
rect
void DrawImageFromRect(Image* image, const RectF& src, const RectF& dest)
Draw the specified portion of image
at src
to fit rect
.
Parameters
Image*
imageconst RectF&
srcconst RectF&
dest
void DrawCanvas(Canvas* canvas, const RectF& rect)
Draw scaled canvas
to fit rect
.
Parameters
Canvas*
canvasconst RectF&
rect
void DrawCanvasFromRect(Canvas* canvas, const RectF& src, const RectF& dest)
Draw the specified portion of canvas
at src
to fit rect
.
Parameters
Canvas*
canvasconst RectF&
srcconst RectF&
dest
void DrawAttributedText(scoped_refptr<AttributedText> text, const RectF& rect)
Draw text
bounded by rect
.
Parameters
void DrawText(const std::string& text, const RectF& rect, const TextAttributes& attributes)
Draw text
with attributes
bounded by rect
.
Parameters
const std::string&
textconst RectF&
rectconst TextAttributes&
attributes