sf-svg
|
SVG-XML image support for SFML. More...
#include <Svg.hpp>
Public Member Functions | |
SVGImage () | |
Default Constructor. More... | |
SVGImage (const std::string &file, const float dpi=96.f) | |
Constructor loading from file. More... | |
void | setMode (const DrawMode m_mode) |
Set curve drawing mode. More... | |
bool | loadFromFile (const std::string &file, const float dpi=96.f) |
Opens .svg file. More... | |
bool | loadFromMemory (const void *data, size_t size, const float dpi=96.f) |
Loads SVG image from memory. More... | |
bool | loadFromStream (sf::InputStream &stream, const float dpi=96.f) |
Loads SVG image from stream. More... | |
sf::Image | rasterize (const float scale=1.f) |
Rasterizes SVG. More... | |
void | move (sf::Vector2f vec) |
Translate image. More... | |
void | scale (const float factor) |
Scale image. More... | |
sf::Vector2f | getSize () const |
Returns size of image. More... | |
SVG-XML image support for SFML.
Class uses Cubic Bezier Curves to draw SVG graphics, can be drawn as set of curves or rasterized to create normal sf::Image.
sfc::SVGImage::SVGImage | ( | ) |
Default Constructor.
Initializes internal variables
sfc::SVGImage::SVGImage | ( | const std::string & | file, |
const float | dpi = 96.f |
||
) |
Constructor loading from file.
[in] | file | – path to .svg file |
[in] | dpi | – dots per inch/passed to nanosvg |
Calls loadFromFile with given params
sf::Vector2f sfc::SVGImage::getSize | ( | ) | const |
Returns size of image.
bool sfc::SVGImage::loadFromFile | ( | const std::string & | file, |
const float | dpi = 96.f |
||
) |
Opens .svg file.
[in] | file | – path to .svg file |
[in] | dpi | – dots per inch/passed to nanosvg |
Method that parses .svg file and creates proper Bezier Curves.
bool sfc::SVGImage::loadFromMemory | ( | const void * | data, |
size_t | size, | ||
const float | dpi = 96.f |
||
) |
Loads SVG image from memory.
[in] | data | – pointer to null-terminated data |
[in] | size | – data count |
[in] | dpi | – dots per inch/passed to nanosvg |
Method that parses SVG-XML image from memory and creates proper Bezier Curves.
bool sfc::SVGImage::loadFromStream | ( | sf::InputStream & | stream, |
const float | dpi = 96.f |
||
) |
Loads SVG image from stream.
[in] | stream | – SFML input stream instance |
[in] | dpi | – dots per inch/passed to nanosvg |
Method that parses SVG-XML image from SFML input stream and creates proper Bezier Curves.
void sfc::SVGImage::move | ( | sf::Vector2f | vec | ) |
Translate image.
[in] | vec | – vector by which image will be translated |
sf::Image sfc::SVGImage::rasterize | ( | const float | scale = 1.f | ) |
Rasterizes SVG.
[in] | scale | – factor to scale the image by/passed to nanosvg |
void sfc::SVGImage::scale | ( | const float | factor | ) |
Scale image.
[in] | factor | – scale to apply |
void sfc::SVGImage::setMode | ( | const DrawMode | m_mode | ) |
Set curve drawing mode.
[in] | mode | – Drawing mode (normal / debug) |
If DrawMode::DEBUG parameter is given, non-rasterized image shows points used to create curves. Remember, new mode is applied only after re-loading SVG image!