Donner 0.5.0
Embeddable browser-grade SVG2 engine
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 bool IsTinySkiaBackend ()
 Returns true when the active test renderer backend is tiny-skia.
static std::string snapshotToAscii (const RendererBitmap &snapshot)
 Convert a snapshot bitmap to ASCII art, mapping grayscale intensity to ten glyph levels.
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

◆ renderToAsciiImage() [1/2]

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:236
Stores an ASCII representation of a rendered image, and supports diffing it to another image.
Definition RendererTestUtils.h:21
Parameters
svgFragmentThe SVG fragment to render.
sizeThe size of the generated image.

◆ renderToAsciiImage() [2/2]

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.

◆ snapshotToAscii()

std::string donner::svg::RendererTestUtils::snapshotToAscii ( const RendererBitmap & snapshot)
inlinestatic

Convert a snapshot bitmap to ASCII art, mapping grayscale intensity to ten glyph levels.

Parameters
snapshotRenderer snapshot in RGBA format.
Returns
ASCII art with one newline-terminated row per image row.

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