tiny-skia-cpp
A C++20 2D rendering library (port of tiny-skia)
Loading...
Searching...
No Matches
tiny_skia::Canvas Class Reference

Drawing surface backed by a mutable pixel buffer. More...

#include <tiny_skia/Canvas.h>

Public Member Functions

 Canvas (MutablePixmapView view)
 Constructs a Canvas from a mutable view.
 
 Canvas (Pixmap &pixmap)
 Constructs a Canvas from an owned Pixmap.
 
void fillRect (const Rect &rect, const Paint &paint, Transform transform=Transform::identity(), const Mask *mask=nullptr)
 Fills an axis-aligned rectangle.
 
void fillPath (const Path &path, const Paint &paint, FillRule fillRule, Transform transform=Transform::identity(), const Mask *mask=nullptr)
 Fills a path using the given fill rule.
 
void strokePath (const Path &path, const Paint &paint, const Stroke &stroke, Transform transform=Transform::identity(), const Mask *mask=nullptr)
 Strokes a path with the given stroke settings.
 
void drawPixmap (std::int32_t x, std::int32_t y, PixmapView src, const PixmapPaint &paint, Transform transform=Transform::identity(), const Mask *mask=nullptr)
 Composites a source pixmap onto this canvas at offset (x, y).
 
void applyMask (const Mask &mask)
 Applies a mask to already-drawn content.
 

Detailed Description

Canvas wraps a MutablePixmapView (or a Pixmap) and provides the primary drawing API: fillRect, fillPath, strokePath, drawPixmap, and applyMask.

auto pixmap = Pixmap::fromSize(500, 500).value();
Canvas canvas(pixmap);
canvas.fillPath(path, paint, FillRule::Winding);
Drawing surface backed by a mutable pixel buffer.
Definition Canvas.h:29
static std::optional< Pixmap > fromSize(std::uint32_t width, std::uint32_t height)
Creates a zero-filled pixmap. Returns nullopt for zero dimensions.

The documentation for this class was generated from the following file: