|
|
Donner
C++20 SVG rendering library
|
Rendering backend using Skia, https://github.com/google/skia. More...
#include "donner/svg/renderer/RendererSkia.h"
Classes | |
| class | Impl |
| Implementation class for RendererSkia. More... | |
Public Member Functions | |
| RendererSkia (bool verbose=false) | |
| Create the Skia renderer. | |
| ~RendererSkia () | |
| Destructor. | |
| RendererSkia (RendererSkia &&) noexcept | |
| Move constructor. | |
| RendererSkia & | operator= (RendererSkia &&) noexcept |
| Move assignment operator. | |
| RendererSkia (const RendererSkia &)=delete | |
| RendererSkia & | operator= (const RendererSkia &)=delete |
| void | draw (SVGDocument &document) |
| Draw the SVG document using the renderer. | |
| std::string | drawIntoAscii (SVGDocument &document) |
| Render the given SVGDocument into ASCII art. | |
| sk_sp< SkPicture > | drawIntoSkPicture (SVGDocument &document) |
| Draw the given SVGDocument into a SkPicture, for offscreen rendering or debugging purposes. | |
| bool | save (const char *filename) |
| Save the rendered image to a PNG file. | |
| std::span< const uint8_t > | pixelData () const |
| Get the pixel data of the rendered image. | |
| int | width () const |
| Get the width of the rendered image in pixels. | |
| int | height () const |
| Get the height of the rendered image in pixels. | |
| const SkBitmap & | bitmap () const |
| Get the SkBitmap of the rendered image. | |
| void | setAntialias (bool antialias) |
| Enable or disable antialiasing. | |
Rendering backend using Skia, https://github.com/google/skia.
Skia is a 2D graphics library that powers Chrome, Firefox, Android, and many other projects, and supports all functionality required to implement SVG (as many of these projects also support SVG).
Skia is used as the reference renderer while implementing Donner, but long-term Donner would like to support other rendering backends, so dependencies on Skia should be kept to a minimum and isolated to RendererSkia.
This is a prototype-quality implementation, and is subject to refactoring in the future to provide a cleaner API boundary between Donner and the rendering backend.
|
explicit |
Create the Skia renderer.
| verbose | If true, print verbose logging. |
| void donner::svg::RendererSkia::draw | ( | SVGDocument & | document | ) |
Draw the SVG document using the renderer.
Writes to an internal bitmap, which can be retrieved using the bitmap() method.
| document | The SVG document to render. |
| std::string donner::svg::RendererSkia::drawIntoAscii | ( | SVGDocument & | document | ) |
Render the given SVGDocument into ASCII art.
The generated image is of given size, and has a black background.
Colors will be mapped to ASCII characters, with @ white all the way to . black, with ten shades of gray.
For example:
Renders as:
| document | SVG document to render, of max size 64x64. |
| sk_sp< SkPicture > donner::svg::RendererSkia::drawIntoSkPicture | ( | SVGDocument & | document | ) |
Draw the given SVGDocument into a SkPicture, for offscreen rendering or debugging purposes.
| document | The SVG document to render. |
| std::span< const uint8_t > donner::svg::RendererSkia::pixelData | ( | ) | const |
| bool donner::svg::RendererSkia::save | ( | const char * | filename | ) |
Save the rendered image to a PNG file.
| filename | The filename to save the PNG to. |
|
inline |
Enable or disable antialiasing.
On by default.
| antialias | Whether to enable antialiasing. |