SVG for C++
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions
SVG Namespace Reference

Main namespace for SVG for C++. More...

Classes

class  AttributeMap
 Base class for anything that has attributes (e.g. SVG elements, CSS stylesheets) More...
 
struct  Attrs
 
struct  AutoscaleOptions
 
class  Circle
 
class  Classes
 
class  ClassList
 Ordered token list for managing the class attribute. More...
 
struct  ClassSpec
 
class  Color
 
class  Defs
 
class  Element
 Abstract base class for all SVG elements. More...
 
class  Group
 
class  Line
 
class  LinearGradient
 
class  Path
 
class  Polygon
 
struct  QuadCoord
 
class  RadialGradient
 
class  Rect
 
class  Shape
 Base class for any SVG elements that have a width and height. More...
 
class  SVG
 
class  Symbol
 
class  Text
 
class  Title
 
class  TransformList
 Ordered function list for managing the transform attribute. More...
 
class  Use
 
class  Variables
 
struct  VariableSpec
 

Typedefs

using SelectorProperties = std::map< std::string, AttributeMap >
 
using SVGAttrib = std::map< std::string, std::string >
 
using Point = std::pair< double, double >
 
using Margins = QuadCoord
 
using Alignment = unsigned
 
using G = Group
 

Enumerations

enum class  ElementKind {
  Custom , Defs , LinearGradient , RadialGradient ,
  Stop , Symbol , Use , SVG ,
  Style , Path , Text , Title ,
  Group , Line , Rect , Circle ,
  Polygon
}
 
enum class  RelativeAlignment : unsigned { Left = 1u << 0 , Top = 1u << 1 , Right = 1u << 2 , Bottom = 1u << 3 }
 
enum class  Anchor : unsigned { Start = 1u << 4 , Center = 1u << 5 , End = 1u << 6 }
 
enum class  Axis { X , Y }
 

Functions

std::string tag_name (ElementKind kind)
 
Alignment operator| (RelativeAlignment relative, Anchor anchor)
 
Alignment operator| (Anchor anchor, RelativeAlignment relative)
 
std::string to_string (const double &value)
 
std::string to_string (const Point &point)
 
std::string to_string (const Color &color)
 
std::string to_string (const std::map< std::string, AttributeMap > &css, const size_t indent_level=0)
 
std::string escape_xml (const std::string &text)
 
std::vector< Point > bounding_polygon (const std::vector< Shape * > &shapes)
 
SVG frame_animate (std::vector< SVG > &frames, const double fps)
 
SVG merge (SVG &left, SVG &right, const Margins &margins=DEFAULT_MARGINS)
 
SVG merge (std::vector< SVG > &frames, const double width, const int max_frame_width)
 
std::vector< Point > bounding_polygon (std::vector< Shape * > &shapes)
 

Detailed Description

Main namespace for SVG for C++.

Typedef Documentation

◆ Alignment

using SVG::Alignment = typedef unsigned

Bitwise combination of RelativeAlignment and Anchor.

◆ G

using SVG::G = typedef Group

Short alias for Group, matching SVG's native g tag name.

◆ SelectorProperties

using SVG::SelectorProperties = typedef std::map<std::string, AttributeMap>

A mapping of CSS selectors to their corresponding style attributes

Enumeration Type Documentation

◆ Anchor

enum class SVG::Anchor : unsigned
strong

Anchor point along one axis of an element's layout bounds.

◆ Axis

enum class SVG::Axis
strong

Axis used when aligning two elements without making them neighbors.

◆ ElementKind

enum class SVG::ElementKind
strong

Stable element categories used for typed lookup without requiring RTTI.

◆ RelativeAlignment

enum class SVG::RelativeAlignment : unsigned
strong

Side of a target element where another element should be positioned.

Function Documentation

◆ escape_xml()

std::string SVG::SVG::escape_xml ( const std::string &  text)
inline

Escape text for XML element content or attribute values.

◆ frame_animate()

SVG SVG::SVG::frame_animate ( std::vector< SVG > &  frames,
const double  fps 
)
inline

Given a vector of SVGs, create a frame-by-frame animation of them.

Given a vector of SVGs, create a frame-by-frame animation of them.

◆ merge() [1/2]

SVG SVG::merge ( std::vector< SVG > &  frames,
const double  width,
const int  max_frame_width 
)
inline

Given a vector of SVGs, merge them together max_frame_width: Maximum width of any individual frame

Given a vector of SVGs, merge them together max_frame_width: Maximum width of any individual frame

◆ merge() [2/2]

SVG SVG::SVG::merge ( SVG left,
SVG right,
const Margins margins = DEFAULT_MARGINS 
)
inline

Merge two SVG documents together horizontally with a uniform margin

Merge two SVG documents together horizontally with a uniform margin

◆ tag_name()

std::string SVG::tag_name ( ElementKind  kind)
inline

Return the native SVG tag name for a built-in kind, or an empty string for Custom.

◆ to_string() [1/4]

std::string SVG::SVG::to_string ( const Color color)
inline

Return the serialized CSS color token.

Return the serialized CSS color token.

Return the serialized CSS color token.

◆ to_string() [2/4]

std::string SVG::to_string ( const double &  value)
inline

Trim off all but one decimal place when converting a double to string

Trim off all but one decimal place when converting a double to string

◆ to_string() [3/4]

std::string SVG::SVG::to_string ( const Point &  point)
inline

Return a string representation of a point as "x,y"

Return a string representation of a point as "x,y"

◆ to_string() [4/4]

std::string SVG::to_string ( const std::map< std::string, AttributeMap > &  css,
const size_t  indent_level = 0 
)
inline

Print out a CSS attribute block

Print out a CSS attribute block