NovaSVG 0.11.5
An SVG library
Loading...
Searching...
No Matches
nova::svg::element Class Reference

#include <svg.h>

Inheritance diagram for nova::svg::element:
Collaboration diagram for nova::svg::element:

Public Member Functions

 element ()=default
 Constructs a null el.
bool has_attribute (const std::string &name) const
 Checks if the el has a specific attribute.
const std::string & attribute (const std::string &name) const
 Retrieves the value of an attribute.
void set_attribute (const std::string &name, const std::string &value)
 Sets the value of an attribute.
void render (stb::image &image, const stb::matrix &matrix=stb::matrix()) const
 Renders the el onto an existing image, using a transformation matrix.
stb::image render_to_image (int width=-1, int height=-1, const stb::color &background_color=stb::color(0, 0, 0, 0)) const
 Renders the el to a new straight-alpha RGBA image with specified dimensions.
void render (pixmap &bitmap, const stb::matrix &matrix=stb::matrix()) const
pixmap render_to_pixmap (int width=-1, int height=-1, const stb::color &background_color=stb::color(0, 0, 0, 0)) const
stb::matrix local_matrix () const
 Retrieves the local transformation matrix of the el.
stb::matrix global_matrix () const
 Retrieves the global transformation matrix of the el.
box local_bounding_box () const
 Retrieves the local bounding box of the el.
box global_bounding_box () const
 Retrieves the global bounding box of the el.
box bounding_box () const
 Retrieves the bounding box of the el without any transformations.
node_list children () const
 Returns the child nodes of this nd.
Public Member Functions inherited from nova::svg::node
 node ()=default
 Constructs a null nd.
bool is_text_node () const
 Checks if the nd is a text nd.
bool is_element () const
 Checks if the nd is an el nd.
text_node to_text_node () const
 Converts the nd to a text_node.
element to_element () const
 Converts the nd to an element.
element parent_element () const
 Returns the parent el.
bool is_null () const
 Checks if the nd is null.
 operator bool () const
 Checks if the nd is not null.
bool operator== (const node &nd) const
 Checks if two nodes are equal.
bool operator!= (const node &nd) const
 Checks if two nodes are not equal.

Friends

class node
class document

Additional Inherited Members

Protected Member Functions inherited from nova::svg::node
 node (svg_node *nd)
svg_node * nd () const
Protected Attributes inherited from nova::svg::node
svg_node * m_node {nullptr}

Detailed Description

Definition at line 192 of file svg.h.

Constructor & Destructor Documentation

◆ element()

nova::svg::element::element ( )
default

Constructs a null el.

Referenced by children().

Member Function Documentation

◆ attribute()

const std::string & nova::svg::element::attribute ( const std::string & name) const

Retrieves the value of an attribute.

Parameters
nameThe name of the attribute to retrieve.
Returns
The value of the attribute as a string.

◆ bounding_box()

box nova::svg::element::bounding_box ( ) const

Retrieves the bounding box of the el without any transformations.

Returns
A Box representing the bounding box of the el without any transformations applied.

◆ children()

node_list nova::svg::element::children ( ) const

Returns the child nodes of this nd.

Returns
A NodeList containing the child nodes.

References element().

◆ global_bounding_box()

box nova::svg::element::global_bounding_box ( ) const

Retrieves the global bounding box of the el.

Returns
A Box representing the bounding box after applying global transformations.

◆ global_matrix()

stb::matrix nova::svg::element::global_matrix ( ) const

Retrieves the global transformation matrix of the el.

Returns
The matrix combining the el's local and all parent transformations.

◆ has_attribute()

bool nova::svg::element::has_attribute ( const std::string & name) const

Checks if the el has a specific attribute.

Parameters
nameThe name of the attribute to check.
Returns
True if the el has the specified attribute, false otherwise.

◆ local_bounding_box()

box nova::svg::element::local_bounding_box ( ) const

Retrieves the local bounding box of the el.

Returns
A Box representing the bounding box after applying local transformations.

◆ local_matrix()

stb::matrix nova::svg::element::local_matrix ( ) const

Retrieves the local transformation matrix of the el.

Returns
The matrix that applies only to the el, relative to its parent.

◆ render() [1/2]

void nova::svg::element::render ( pixmap & bitmap,
const stb::matrix & matrix = stb::matrix() ) const

◆ render() [2/2]

void nova::svg::element::render ( stb::image & image,
const stb::matrix & matrix = stb::matrix() ) const

Renders the el onto an existing image, using a transformation matrix.

The el is drawn on a transparent layer the size of image and the layer is composited over the image's pixels with stb::image::blend (normal mode, "over" with straight alpha). Because the layer starts transparent, mix-blend-mode inside the el blends against the layer, not against what was already in image. Any pixel format is accepted; images larger than 32767 pixels on a side are left untouched.

Parameters
imageThe image to render onto (changed in place).
matrixThe root transformation matrix.

◆ render_to_image()

stb::image nova::svg::element::render_to_image ( int width = -1,
int height = -1,
const stb::color & background_color = stb::color(0, 0, 0, 0) ) const

Renders the el to a new straight-alpha RGBA image with specified dimensions.

Parameters
widthThe desired width in pixels, or -1 to auto-scale based on the intrinsic size.
heightThe desired height in pixels, or -1 to auto-scale based on the intrinsic size.
backgroundColorThe background color to render onto.
Returns
The rendered image, or an empty image if the el has nothing to draw or memory ran out.

◆ render_to_pixmap()

pixmap nova::svg::element::render_to_pixmap ( int width = -1,
int height = -1,
const stb::color & background_color = stb::color(0, 0, 0, 0) ) const

◆ set_attribute()

void nova::svg::element::set_attribute ( const std::string & name,
const std::string & value )

Sets the value of an attribute.

Parameters
nameThe name of the attribute to set.
valueThe value to assign to the attribute.

◆ document

friend class document
friend

Definition at line 292 of file svg.h.

References document.

Referenced by document.

◆ node

friend class node
friend

Definition at line 291 of file svg.h.

References node.

Referenced by node.


The documentation for this class was generated from the following file:
  • /home/runner/work/novasvg/novasvg/include/nova/svg/svg.h