sf-svg
Public Member Functions | List of all members
sfc::SVGImage Class Reference

SVG-XML image support for SFML. More...

#include <Svg.hpp>

Inheritance diagram for sfc::SVGImage:
Inheritance graph
[legend]

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ SVGImage() [1/2]

sfc::SVGImage::SVGImage ( )

Default Constructor.

Initializes internal variables

◆ SVGImage() [2/2]

sfc::SVGImage::SVGImage ( const std::string &  file,
const float  dpi = 96.f 
)

Constructor loading from file.

Parameters
[in]file– path to .svg file
[in]dpi– dots per inch/passed to nanosvg

Calls loadFromFile with given params

Member Function Documentation

◆ getSize()

sf::Vector2f sfc::SVGImage::getSize ( ) const

Returns size of image.

Returns
sf::Vector2f (size)

◆ loadFromFile()

bool sfc::SVGImage::loadFromFile ( const std::string &  file,
const float  dpi = 96.f 
)

Opens .svg file.

Parameters
[in]file– path to .svg file
[in]dpi– dots per inch/passed to nanosvg
Returns
True if ok, False otherwise

Method that parses .svg file and creates proper Bezier Curves.

◆ loadFromMemory()

bool sfc::SVGImage::loadFromMemory ( const void *  data,
size_t  size,
const float  dpi = 96.f 
)

Loads SVG image from memory.

Parameters
[in]data– pointer to null-terminated data
[in]size– data count
[in]dpi– dots per inch/passed to nanosvg
Returns
True if ok, False otherwise

Method that parses SVG-XML image from memory and creates proper Bezier Curves.

◆ loadFromStream()

bool sfc::SVGImage::loadFromStream ( sf::InputStream &  stream,
const float  dpi = 96.f 
)

Loads SVG image from stream.

Parameters
[in]stream– SFML input stream instance
[in]dpi– dots per inch/passed to nanosvg
Returns
True if ok, False otherwise

Method that parses SVG-XML image from SFML input stream and creates proper Bezier Curves.

◆ move()

void sfc::SVGImage::move ( sf::Vector2f  vec)

Translate image.

Parameters
[in]vec– vector by which image will be translated

◆ rasterize()

sf::Image sfc::SVGImage::rasterize ( const float  scale = 1.f)

Rasterizes SVG.

Parameters
[in]scale– factor to scale the image by/passed to nanosvg
Returns
Rasterized sf::Image

◆ scale()

void sfc::SVGImage::scale ( const float  factor)

Scale image.

Parameters
[in]factor– scale to apply

◆ setMode()

void sfc::SVGImage::setMode ( const DrawMode  m_mode)

Set curve drawing mode.

Parameters
[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!


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