NovaSVG 0.10.0
A header-only SVG library
Loading...
Searching...
No Matches
novasvg::Element Class Reference

#include <novasvg.h>

Inheritance diagram for novasvg::Element:
Collaboration diagram for novasvg::Element:

Public Member Functions

 Element ()=default
 Constructs a null element.
 
bool hasAttribute (const std::string &name) const
 Checks if the element has a specific attribute.
 
const std::string & getAttribute (const std::string &name) const
 Retrieves the value of an attribute.
 
void setAttribute (const std::string &name, const std::string &value)
 Sets the value of an attribute.
 
void render (Bitmap &bitmap, const Matrix &matrix=Matrix()) const
 Renders the element onto a bitmap using a transformation matrix.
 
Bitmap renderToBitmap (int width=-1, int height=-1, const Color &backgroundColor=Color(0, 0, 0, 0)) const
 Renders the element to a bitmap with specified dimensions.
 
Matrix getLocalMatrix () const
 Retrieves the local transformation matrix of the element.
 
Matrix getGlobalMatrix () const
 Retrieves the global transformation matrix of the element.
 
Box getLocalBoundingBox () const
 Retrieves the local bounding box of the element.
 
Box getGlobalBoundingBox () const
 Retrieves the global bounding box of the element.
 
Box getBoundingBox () const
 Retrieves the bounding box of the element without any transformations.
 
NodeList children () const
 Returns the child nodes of this node.
 
- Public Member Functions inherited from novasvg::Node
 Node ()=default
 Constructs a null node.
 
bool isTextNode () const
 Checks if the node is a text node.
 
bool isElement () const
 Checks if the node is an element node.
 
TextNode toTextNode () const
 Converts the node to a TextNode.
 
Element toElement () const
 Converts the node to an Element.
 
Element parentElement () const
 Returns the parent element.
 
bool isNull () const
 Checks if the node is null.
 
 operator bool () const
 Checks if the node is not null.
 
bool operator== (const Node &node) const
 Checks if two nodes are equal.
 
bool operator!= (const Node &node) const
 Checks if two nodes are not equal.
 

Friends

class Node
 
class Document
 

Additional Inherited Members

- Protected Member Functions inherited from novasvg::Node
 Node (SVGNode *node)
 
SVGNode * node () const
 
- Protected Attributes inherited from novasvg::Node
SVGNode * m_node {nullptr}
 

Detailed Description

Definition at line 460 of file novasvg.h.

Constructor & Destructor Documentation

◆ Element()

novasvg::Element::Element ( )
default

Constructs a null element.

Member Function Documentation

◆ children()

NodeList novasvg::Element::children ( ) const
inline

Returns the child nodes of this node.

Returns
A NodeList containing the child nodes.

Definition at line 993 of file novasvg.h.

References novasvg::SVGElement::children(), children(), and novasvg::Node::m_node.

Referenced by children().

◆ getAttribute()

const std::string & novasvg::Element::getAttribute ( const std::string &  name) const
inline

Retrieves the value of an attribute.

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

Definition at line 910 of file novasvg.h.

References novasvg::emptyString, novasvg::SVGElement::getAttribute(), and novasvg::Node::m_node.

◆ getBoundingBox()

Box novasvg::Element::getBoundingBox ( ) const
inline

Retrieves the bounding box of the element without any transformations.

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

Definition at line 986 of file novasvg.h.

References novasvg::Node::m_node, and novasvg::SVGElement::paintBoundingBox().

Referenced by getGlobalBoundingBox(), and getLocalBoundingBox().

◆ getGlobalBoundingBox()

Box novasvg::Element::getGlobalBoundingBox ( ) const
inline

Retrieves the global bounding box of the element.

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

Definition at line 981 of file novasvg.h.

References getBoundingBox(), getGlobalMatrix(), and novasvg::Box::transformed().

◆ getGlobalMatrix()

Matrix novasvg::Element::getGlobalMatrix ( ) const
inline

Retrieves the global transformation matrix of the element.

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

Definition at line 966 of file novasvg.h.

References novasvg::SVGElement::localTransform(), novasvg::Node::m_node, novasvg::Node::parentElement(), and novasvg::Transform::postMultiply().

Referenced by getGlobalBoundingBox().

◆ getLocalBoundingBox()

Box novasvg::Element::getLocalBoundingBox ( ) const
inline

Retrieves the local bounding box of the element.

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

Definition at line 976 of file novasvg.h.

References getBoundingBox(), getLocalMatrix(), and novasvg::Box::transformed().

◆ getLocalMatrix()

Matrix novasvg::Element::getLocalMatrix ( ) const
inline

Retrieves the local transformation matrix of the element.

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

Definition at line 959 of file novasvg.h.

References novasvg::SVGElement::localTransform(), and novasvg::Node::m_node.

Referenced by getLocalBoundingBox().

◆ hasAttribute()

bool novasvg::Element::hasAttribute ( const std::string &  name) const
inline

Checks if the element has a specific attribute.

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

Definition at line 903 of file novasvg.h.

References novasvg::SVGElement::hasAttribute(), and novasvg::Node::m_node.

◆ render()

void novasvg::Element::render ( Bitmap &  bitmap,
const Matrix &  matrix = Matrix() 
) const
inline

Renders the element onto a bitmap using a transformation matrix.

Parameters
bitmapThe bitmap to render onto.
Theroot transformation matrix.

Definition at line 924 of file novasvg.h.

References novasvg::Bitmap::isNull(), novasvg::Node::m_node, novasvg::Painting, and novasvg::SVGElement::render().

Referenced by renderToBitmap().

◆ renderToBitmap()

Bitmap novasvg::Element::renderToBitmap ( int  width = -1,
int  height = -1,
const Color &  backgroundColor = Color(0, 0, 0, 0) 
) const
inline

Renders the element to a bitmap 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
A Bitmap containing the raster representation of the element.

Definition at line 933 of file novasvg.h.

References novasvg::Bitmap::clear(), novasvg::SVGElement::localTransform(), novasvg::Node::m_node, novasvg::Transform::mapRect(), render(), and novasvg::Color::value().

◆ setAttribute()

void novasvg::Element::setAttribute ( const std::string &  name,
const std::string &  value 
)
inline

Sets the value of an attribute.

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

Definition at line 917 of file novasvg.h.

References novasvg::Node::m_node, and novasvg::SVGElement::setAttribute().

Friends And Related Symbol Documentation

◆ Document

friend class Document
friend

Definition at line 544 of file novasvg.h.

◆ Node

friend class Node
friend

Definition at line 543 of file novasvg.h.


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