SVG for C++
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Typedefs | Enumerations | Functions
svg.hpp File Reference
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <fstream>
#include <functional>
#include <math.h>
#include <map>
#include <deque>
#include <set>
#include <vector>
#include <string>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <memory>
#include <stdexcept>
#include <type_traits>
#include <tuple>
#include <utility>

Go to the source code of this file.

Classes

struct  SVG::QuadCoord
 
struct  SVG::Attrs
 
struct  SVG::AutoscaleOptions
 
class  SVG::Color
 
class  SVG::ClassList
 Ordered token list for managing the class attribute. More...
 
class  SVG::TransformList
 Ordered function list for managing the transform attribute. More...
 
class  SVG::AttributeMap
 Base class for anything that has attributes (e.g. SVG elements, CSS stylesheets) More...
 
struct  SVG::AttributeMap::AttrSetter
 
struct  SVG::VariableSpec< T >
 
struct  SVG::ClassSpec< T >
 
class  SVG::Variables< T >
 
class  SVG::Classes< T >
 
class  SVG::Element
 Abstract base class for all SVG elements. More...
 
class  SVG::Element::BoundingBox
 Represents the top left and bottom right corners of a bounding rectangle. More...
 
struct  SVG::Element::TraversalOptions
 
class  SVG::Element::DepthFirstIterator
 
class  SVG::Element::ConstDepthFirstIterator
 
class  SVG::Element::DepthFirstRange
 
class  SVG::Element::ConstDepthFirstRange
 
class  SVG::Shape
 Base class for any SVG elements that have a width and height. More...
 
class  SVG::Defs
 
class  SVG::LinearGradient
 
class  SVG::RadialGradient
 
class  SVG::Symbol
 
class  SVG::Use
 
class  SVG::SVG
 
class  SVG::SVG::Style
 
class  SVG::Path
 
class  SVG::Text
 
class  SVG::Title
 
class  SVG::Group
 
class  SVG::Line
 
class  SVG::Rect
 
class  SVG::Circle
 
class  SVG::Polygon
 

Namespaces

namespace  SVG
 Main namespace for SVG for C++.
 
namespace  util
 Various utility and mathematical functions.
 

Macros

#define PI   3.14159265
 
#define RAD_TO_DEG   (180/PI)
 
#define SVG_TYPE_CHECK   static_assert(std::is_base_of<Element, T>::value, "Child must be an SVG element.")
 
#define APPROX_EQUALS(x, y, tol)   bool(abs(x - y) < tol)
 

Typedefs

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

Enumerations

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

Functions

std::string SVG::tag_name (ElementKind kind)
 
Alignment SVG::operator| (RelativeAlignment relative, Anchor anchor)
 
Alignment SVG::operator| (Anchor anchor, RelativeAlignment relative)
 
std::string SVG::to_string (const double &value)
 
std::string SVG::to_string (const Point &point)
 
std::string SVG::to_string (const Color &color)
 
std::string SVG::to_string (const std::map< std::string, AttributeMap > &css, const size_t indent_level=0)
 
std::string SVG::escape_xml (const std::string &text)
 
std::vector< Point > SVG::bounding_polygon (const std::vector< Shape * > &shapes)
 
SVG SVG::frame_animate (std::vector< SVG > &frames, const double fps)
 
SVG SVG::merge (SVG &left, SVG &right, const Margins &margins=DEFAULT_MARGINS)
 
SVG SVG::merge (std::vector< SVG > &frames, const double width, const int max_frame_width)
 
std::string SVG::detail::text_content_element_to_string (const Element &element, const std::string &tag, const std::string &content, const size_t indent_level)
 
unsigned SVG::detail::alignment_count_bits (Alignment value)
 
bool SVG::detail::bbox_is_measured (const Element::BoundingBox &bbox)
 
double SVG::detail::visible_stroke_width (const Element &element)
 
bool SVG::detail::renders_in_place (const Element *element)
 
double SVG::detail::bbox_center_x (const Element::BoundingBox &bbox)
 
double SVG::detail::bbox_center_y (const Element::BoundingBox &bbox)
 
double SVG::detail::bbox_anchor_x (const Element::BoundingBox &bbox, Anchor anchor)
 
double SVG::detail::bbox_anchor_y (const Element::BoundingBox &bbox, Anchor anchor)
 
std::vector< Point > SVG::bounding_polygon (std::vector< Shape * > &shapes)
 

Function Documentation

◆ text_content_element_to_string()

std::string SVG::detail::text_content_element_to_string ( const Element element,
const std::string &  tag,
const std::string &  content,
const size_t  indent_level 
)
inlineprotected

Shared serializer for elements whose children are escaped text content.