|
|
Donner
C++20 SVG rendering library
|
Base class for SVG gradient elements, such as SVGLinearGradientElement and SVGRadialGradientElement. More...
#include "donner/svg/SVGGradientElement.h"
Public Member Functions | |
| std::optional< RcString > | href () const |
| href attribute to allow inheriting attributes from another gradient. | |
| GradientUnits | gradientUnits () const |
| gradientUnits attribute to specify the coordinate system for the gradient. | |
| Transformd | gradientTransform () const |
| gradientTransform attribute to specify a transform to apply to the gradient. | |
| GradientSpreadMethod | spreadMethod () const |
| spreadMethod attribute to specify how to fill the area outside the gradient. | |
| void | setHref (const std::optional< RcString > &value) |
| href attribute to allow inheriting attributes from another gradient. | |
| void | setGradientUnits (GradientUnits value) |
| gradientUnits attribute to specify the coordinate system for the gradient. | |
| void | setGradientTransform (const Transformd &value) |
| gradientTransform attribute to specify a transform to apply to the gradient. | |
| void | setSpreadMethod (GradientSpreadMethod value) |
| spreadMethod attribute to specify how to fill the area outside the gradient. | |
| Public Member Functions inherited from donner::svg::SVGElement | |
| SVGElement (const SVGElement &other) | |
| Create another reference to the same SVGElement. | |
| SVGElement (SVGElement &&other) noexcept | |
| Move constructor. | |
| ~SVGElement () noexcept=default | |
| Destructor. | |
| SVGElement & | operator= (const SVGElement &other) |
| Create another reference to the same SVGElement. | |
| SVGElement & | operator= (SVGElement &&other) noexcept |
| Move assignment operator. | |
| ElementType | type () const |
| Get the ElementType for known XML element types. | |
| xml::XMLQualifiedNameRef | tagName () const |
| Get the XML tag name string for this element. | |
| bool | isKnownType () const |
| Returns true if this is a known element type, returns false if this is an SVGUnknownElement. | |
| EntityHandle | entityHandle () const |
| Get the underlying EntityHandle, for advanced use-cases that require direct access to the ECS. | |
| RcString | id () const |
| Get the element id, the value of the "id" attribute. | |
| void | setId (std::string_view id) |
| Set the element id, the value of the "id" attribute. | |
| RcString | className () const |
| Get the element class name, the value of the "class" attribute. | |
| void | setClassName (std::string_view name) |
| Set the element class name, the value of the "class" attribute. | |
| void | setStyle (std::string_view style) |
| Set the element style, the value of the "style" attribute. | |
| void | updateStyle (std::string_view style) |
| Update the element style, adding new attributes or overridding existing ones (without removing them). | |
| ParseResult< bool > | trySetPresentationAttribute (std::string_view name, std::string_view value) |
| Set the value of a presentation attribute, such as "fill" or "stroke". | |
| bool | hasAttribute (const xml::XMLQualifiedNameRef &name) const |
| Returns true if the element has an attribute with the given name. | |
| std::optional< RcString > | getAttribute (const xml::XMLQualifiedNameRef &name) const |
| Get the value of an attribute, if it exists. | |
| SmallVector< xml::XMLQualifiedNameRef, 1 > | findMatchingAttributes (const xml::XMLQualifiedNameRef &matcher) const |
| Find attributes matching the given name matcher. | |
| void | setAttribute (const xml::XMLQualifiedNameRef &name, std::string_view value) |
| Set the value of a generic XML attribute, which may be either a presentation attribute or custom user-provided attribute. | |
| void | removeAttribute (const xml::XMLQualifiedNameRef &name) |
| Remove an attribute, which may be either a presentation attribute or custom user-provided attribute. | |
| SVGDocument | ownerDocument () |
| Get an owning reference to the SVGDocument containing this element. | |
| std::optional< SVGElement > | parentElement () const |
| Get this element's parent, if it exists. | |
| std::optional< SVGElement > | firstChild () const |
| Get the first child of this element, if it exists. | |
| std::optional< SVGElement > | lastChild () const |
| Get the last child of this element, if it exists. | |
| std::optional< SVGElement > | previousSibling () const |
| Get the previous sibling of this element, if it exists. | |
| std::optional< SVGElement > | nextSibling () const |
| Get the next sibling of this element, if it exists. | |
| void | insertBefore (const SVGElement &newNode, std::optional< SVGElement > referenceNode) |
Insert newNode as a child, before referenceNode. | |
| void | appendChild (const SVGElement &child) |
Append child as a child of the current node. | |
| void | replaceChild (const SVGElement &newChild, const SVGElement &oldChild) |
Replace oldChild with newChild in the tree, removing oldChild and inserting newChild in its place. | |
| void | removeChild (const SVGElement &child) |
Remove child from this node. | |
| void | remove () |
| Remove this node from its parent, if it has one. | |
| bool | operator== (const SVGElement &other) const |
| Returns true if the two SVGElement handles reference the same underlying document. | |
| bool | operator!= (const SVGElement &other) const |
| Returns true if the two SVGElement handles reference the same underlying document. | |
| template<typename Derived> | |
| bool | isa () const |
| Return true if this element "is a" instance of type, if it be cast to a specific type with cast. | |
| template<typename Derived> | |
| Derived | cast () |
| Cast this element to its derived type. | |
| template<typename Derived> | |
| Derived | cast () const |
| Cast this element to its derived type (const version). | |
| template<typename Derived> | |
| std::optional< Derived > | tryCast () |
| Cast this element to its derived type, if possible. | |
| template<typename Derived> | |
| std::optional< const Derived > | tryCast () const |
| Cast this element to its derived type, if possible. | |
| std::optional< SVGElement > | querySelector (std::string_view selector) |
| Find the first element in the tree that matches the given CSS selector. | |
| const PropertyRegistry & | getComputedStyle () const |
| Get the computed CSS style of this element, after the CSS cascade. | |
Static Public Member Functions | |
| static constexpr bool | IsBaseOf (ElementType type) |
| Returns true if the given element type can be cast to SVGGradientElement. | |
Protected Member Functions | |
| SVGGradientElement (EntityHandle handle) | |
| Constructor for SVGGradientElement, which must be constructed from a derived class. | |
| Protected Member Functions inherited from donner::svg::SVGElement | |
| SVGElement (EntityHandle handle) | |
| Internal constructor to create an SVGElement from an EntityHandle. | |
| Registry & | registry () const |
| Get the underlying ECS Registry, which holds all data for the document, for advanced use. | |
| EntityHandle | toHandle (Entity entity) const |
| Convert an Entity to an EntityHandle, for advanced use. | |
Friends | |
| class | parser::SVGParserImpl |
Additional Inherited Members | |
| Static Protected Member Functions inherited from donner::svg::SVGElement | |
| static EntityHandle | CreateEmptyEntity (SVGDocument &document) |
| Create a new Entity within the document ECS, and return a handle to it. | |
| static void | CreateEntityOn (EntityHandle handle, const xml::XMLQualifiedNameRef &tagName, ElementType Type) |
| Create a new SVG element instance on a given Entity. | |
| Protected Attributes inherited from donner::svg::SVGElement | |
| EntityHandle | handle_ |
| The underlying ECS Entity for this element, which holds all data. | |
Base class for SVG gradient elements, such as SVGLinearGradientElement and SVGRadialGradientElement.
This stores common attributes for gradients, such as gradientUnits and spreadMethod, and also supports inheriting attributes from other gradients with the href attribute.
| Attribute | Default | Description |
|---|---|---|
| gradientUnits | objectBoundingBox | The coordinate system for the gradient, either userSpaceOnUse or objectBoundingBox. |
| gradientTransform | (none) | A transform to apply to the gradient. |
| spreadMethod | pad | How to handle colors outside the gradient. Either pad, reflect, or repeat. |
| href | (none) | A URL reference to a template gradient element, which is then used as a template for this gradient. Example: <linearGradient id="MyGradient" href="#MyGradient2" /> |
|
explicitprotected |
Constructor for SVGGradientElement, which must be constructed from a derived class.
| handle | The handle to the underlying entity. |
| Transformd donner::svg::SVGGradientElement::gradientTransform | ( | ) | const |
gradientTransform attribute to specify a transform to apply to the gradient.
The default is the identity transform.
| GradientUnits donner::svg::SVGGradientElement::gradientUnits | ( | ) | const |
gradientUnits attribute to specify the coordinate system for the gradient.
The default is GradientUnits::ObjectBoundingBox, where (0, 0) is the top-left corner of the element that references the gradient, and (1, 1) is the bottom-right corner.
This affects the following attributes:
| std::optional< RcString > donner::svg::SVGGradientElement::href | ( | ) | const |
href attribute to allow inheriting attributes from another gradient.
The attributes that can be inherited are:
| void donner::svg::SVGGradientElement::setGradientTransform | ( | const Transformd & | value | ) |
gradientTransform attribute to specify a transform to apply to the gradient.
| value | The transform to apply to the gradient. |
| void donner::svg::SVGGradientElement::setGradientUnits | ( | GradientUnits | value | ) |
gradientUnits attribute to specify the coordinate system for the gradient.
| value | The coordinate system for the gradient. |
| void donner::svg::SVGGradientElement::setHref | ( | const std::optional< RcString > & | value | ) |
href attribute to allow inheriting attributes from another gradient.
| value | URL reference such as "#otherId" to a template gradient element, or std::nullopt to remove the attribute. To be valid, the reference must be to a different "<linearGradient>" or a "<radialGradient>" element. |
| void donner::svg::SVGGradientElement::setSpreadMethod | ( | GradientSpreadMethod | value | ) |
spreadMethod attribute to specify how to fill the area outside the gradient.
| value | The method to use to fill the area outside the gradient. |
| GradientSpreadMethod donner::svg::SVGGradientElement::spreadMethod | ( | ) | const |
spreadMethod attribute to specify how to fill the area outside the gradient.
The default is GradientSpreadMethod::Pad, which fills with the start or end color.
Values for the gradient "spreadMethod" attribute, https://www.w3.org/TR/SVG2/pservers.html#LinearGradientElementSpreadMethodAttribute and https://www.w3.org/TR/SVG2/pservers.html#RadialGradientElementSpreadMethodAttribute.
Specifies what happens at the start or end of a gradient, when the gradient coordinates are inside the bounds of the referencing element.
This is used on "<linearGradient>" and "<radialGradient>" elements.