Lysa  0.0
Lysa 3D Engine
SVG Class Reference

Detailed Description

A 2D shape loaded from an SVG document

+ Inheritance diagram for SVG:

Classes

struct  Segment
 

Public Member Functions

 SVG (const std::string &document, SVGBounds bounds=SVGBounds::DOCUMENT, float strokeWidth=0.0f, float tolerance=DEFAULT_TOLERANCE)
 
const auto & getSegments () const
 
auto getFillRule () const
 
auto getStrokeWidth () const
 
auto getAspectRatio () const
 
auto isEmpty () const
 
- Public Member Functions inherited from UnmanagedResource
 UnmanagedResource ()
 
 UnmanagedResource (const Resource &other)
 
- Public Member Functions inherited from Resource
bool operator== (const Resource &other) const
 
 Resource () = default
 
 Resource (const unique_id id)
 
virtual ~Resource () = default
 

Static Public Member Functions

static SVG load (const std::string &uri, SVGBounds bounds=SVGBounds::DOCUMENT, float strokeWidth=0.0f, float tolerance=DEFAULT_TOLERANCE)
 

Static Public Attributes

static constexpr float DEFAULT_TOLERANCE {0.002f}
 
static constexpr float STROKE_WIDTH_GRID {24.0f}
 
static constexpr float MIN_STROKE_WIDTH {0.5f}
 
static constexpr float MAX_STROKE_WIDTH {5.0f}
 
static constexpr float DEFAULT_STROKE_WIDTH {2.5f}
 

Additional Inherited Members

- Public Attributes inherited from Resource
unique_id id {INVALID_ID}
 

Constructor & Destructor Documentation

SVG ( const std::string &  document,
SVGBounds  bounds = SVGBounds::DOCUMENT,
float  strokeWidth = 0.0f,
float  tolerance = DEFAULT_TOLERANCE 
)
explicit

Parses and flattens an SVG document already in memory.

Parameters
documentContent of the .svg document
boundsBox the geometry is fitted into
strokeWidthWidth replacing the stroke-width of a stroked document,
toleranceMaximum distance between a curve and the segments approximating it, as a fraction of the shape size

Member Function Documentation

auto getAspectRatio ( ) const
inline

Returns the width/height ratio of the box the geometry was fitted into

auto getFillRule ( ) const
inline

Returns the rule used to decide if a point is inside the shape

const auto& getSegments ( ) const
inline

Returns the flattened geometry in the normalized [0.0, 1.0] shape space

auto getStrokeWidth ( ) const
inline

Returns the width of the stroke

auto isEmpty ( ) const
inline

Returns true when the document contains no usable geometry

static SVG load ( const std::string &  uri,
SVGBounds  bounds = SVGBounds::DOCUMENT,
float  strokeWidth = 0.0f,
float  tolerance = DEFAULT_TOLERANCE 
)
static

Loads and flattens an SVG document from the virtual file system.

Parameters
uriURI of the .svg document
boundsBox the geometry is fitted into
strokeWidthWidth replacing the stroke-width of a stroked document,
toleranceMaximum distance between a curve and the segments approximating it, as a fraction of the shape size

Member Data Documentation

constexpr float DEFAULT_STROKE_WIDTH {2.5f}
staticconstexpr

Stroke width of the usual icon sets

constexpr float DEFAULT_TOLERANCE {0.002f}
staticconstexpr

Default flattening tolerance as a fraction of the shape size

constexpr float MAX_STROKE_WIDTH {5.0f}
staticconstexpr

Thickest stroke width an override can ask for

constexpr float MIN_STROKE_WIDTH {0.5f}
staticconstexpr

Thinnest stroke width an override can ask for

constexpr float STROKE_WIDTH_GRID {24.0f}
staticconstexpr

Grid the stroke width overrides are expressed on