Donner
C++20 SVG rendering library
Loading...
Searching...
No Matches
donner::svg::RendererTestUtils Class Reference

Test utilities for rendering and saving SVGs in tests. More...

#include "donner/svg/renderer/tests/RendererTestUtils.h"

Static Public Member Functions

static std::optional< ImagereadRgbaImageFromPngFile (const char *filename)
 Read an RGBA image from a PNG file.
 
static AsciiImage renderToAsciiImage (std::string_view svgFragment, Vector2i size=kTestSvgDefaultSize)
 Render the given SVG fragment into ASCII art.
 
static AsciiImage renderToAsciiImage (SVGDocument document)
 Render the given SVGDocument into ASCII art.
 

Detailed Description

Test utilities for rendering and saving SVGs in tests.

Member Function Documentation

◆ readRgbaImageFromPngFile()

std::optional< Image > donner::svg::RendererTestUtils::readRgbaImageFromPngFile ( const char * filename)
static

Read an RGBA image from a PNG file.

Parameters
filenamePath to a PNG file to load.

◆ renderToAsciiImage() [1/2]

static AsciiImage donner::svg::RendererTestUtils::renderToAsciiImage ( std::string_view svgFragment,
Vector2i size = kTestSvgDefaultSize )
inlinestatic

Render the given SVG fragment into ASCII art.

The generated image is of the 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.

To compare the generated ASCII image to a golden ASCII string, use matches on the returned AsciiImage object.

Example:

<rect width="8" height="8" fill="white" />
)");
static AsciiImage renderToAsciiImage(std::string_view svgFragment, Vector2i size=kTestSvgDefaultSize)
Render the given SVG fragment into ASCII art.
Definition RendererTestUtils.h:153
Stores an ASCII representation of a rendered image, and supports diffing it to another image.
Definition RendererTestUtils.h:31
Parameters
svgFragmentThe SVG fragment to render.
sizeThe size of the generated image.

◆ renderToAsciiImage() [2/2]

static AsciiImage donner::svg::RendererTestUtils::renderToAsciiImage ( SVGDocument document)
inlinestatic

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.

To compare the generated ASCII image to a golden ASCII string, use matches on the returned AsciiImage object.

Parameters
documentSVG document to render, of max size 64x64.

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