Canvas

class Canvas

User-facing drawing API.

Paint-based drawing (advanced)

void draw(Rect r, const Paint &paint)
void draw(Point p1, Point p2, const Paint &paint)

Path drawing

Draw a path with the given paint.

void drawPath(const Path &path, const Paint &paint)

Image rect drawing

Draw an image mapping src rect to dst rect.

void drawImageRect(std::shared_ptr<Image> image, Rect src, Rect dst)
void drawImageRect(std::shared_ptr<Image> image, Rect dst)

Draw an image into the dst rect (src = full image).

Public Functions

explicit Canvas(Device *device)
void clipPath(const Path &path)

Intersect the current clip with a filled path.

void clipRect(Rect r)
void concat(const Matrix &m)
void drawImage(std::shared_ptr<Image> image, f32 x, f32 y)
void drawLine(Point p1, Point p2, Color c, f32 width = 1.0f)
void drawPolyline(const Point *pts, i32 count, Color c, f32 width = 1.0f)
void drawText(Point p, std::string_view text, Color c)
void fillCircle(f32 cx, f32 cy, f32 radius, Color c)
void fillRect(Rect r, Color c)
void fillRoundRect(Rect r, f32 rx, f32 ry, Color c)
Matrix getMatrix() const
void restore()
void rotate(f32 radians)
void save()
void scale(f32 sx, f32 sy)
void setMatrix(const Matrix &m)
void strokeCircle(f32 cx, f32 cy, f32 radius, Color c, f32 width = 1.0f)
void strokeRect(Rect r, Color c, f32 width = 1.0f)
void strokeRoundRect(Rect r, f32 rx, f32 ry, Color c, f32 width = 1.0f)
void translate(f32 dx, f32 dy)

Translate the current transform.