Painter

Graphic context.

Header#include "nativeui/gfx/painter.h"
Namespacenamespace nu
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

void Save()

Save the entire state of the painter.

void Restore()

Restore the most recently saved state.

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

void LineTo(const PointF& point)

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

Parameters

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

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

void Rect(const RectF& rect)

Add rectangle to current path.

Parameters

void Clip()

Add current path to clip area by intersection.

void ClipRect(const RectF& rect)

Add rect to clip area by intersection.

Parameters

void Translate(const Vector2dF& offset)

Add translate transformation which moves the origin by offset.

Parameters

void Rotate(float angle)

Add rotation transformation.

Parameters

void Scale(const Vector2dF& scale)

Add scaling transformation to the painter.

Parameters

void SetColor(Color color)

Set stroke color and fill color to color.

Parameters

void SetStrokeColor(Color color)

Set the color used for shapes' outlines.

Parameters

void SetFillColor(Color color)

Set the color used when filling shapes.

Parameters

void SetLineWidth(float width)

Set the width of lines.

Parameters

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

void FillRect(const RectF& rect)

Draw a filled rectangle.

Parameters

void DrawImage(Image* image, const RectF& rect)

Draw scaled image to fit rect.

Parameters

void DrawImageFromRect(Image* image, const RectF& src, const RectF& dest)

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

Parameters

void DrawCanvas(Canvas* canvas, const RectF& rect)

Draw scaled canvas to fit rect.

Parameters

void DrawCanvasFromRect(Canvas* canvas, const RectF& src, const RectF& dest)

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

Parameters

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