Donner
C++20 SVG rendering library
Loading...
Searching...
No Matches
donner::svg::SVGRadialGradientElement Class Reference

DOM object for a "<radialGradient>" element. More...

#include "donner/svg/SVGRadialGradientElement.h"

Inheritance diagram for donner::svg::SVGRadialGradientElement:
[legend]
Collaboration diagram for donner::svg::SVGRadialGradientElement:
[legend]

Public Member Functions

void setCx (std::optional< Lengthd > value)
 Set the center X coordinate, for the outer circle.
 
void setCy (std::optional< Lengthd > value)
 Set the center Y coordinate, for the outer circle.
 
void setR (std::optional< Lengthd > value)
 Set the radius of the outer circle.
 
void setFx (std::optional< Lengthd > value)
 Set the focal point X coordinate.
 
void setFy (std::optional< Lengthd > value)
 Set the focal point Y coordinate.
 
void setFr (std::optional< Lengthd > value)
 Set the focal point radius.
 
std::optional< Lengthdcx () const
 Get the center X coordinate, for the outer circle.
 
std::optional< Lengthdcy () const
 Get the center Y coordinate, for the outer circle.
 
std::optional< Lengthdr () const
 Get the radius of the outer circle.
 
std::optional< Lengthdfx () const
 Get the focal point X coordinate.
 
std::optional< Lengthdfy () const
 Get the focal point Y coordinate.
 
std::optional< Lengthdfr () const
 Get the focal point radius.
 
- Public Member Functions inherited from donner::svg::SVGGradientElement
std::optional< RcStringhref () 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.
 
SVGElementoperator= (const SVGElement &other)
 Create another reference to the same SVGElement.
 
SVGElementoperator= (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.
 
base::parser::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< RcStringgetAttribute (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< SVGElementparentElement () const
 Get this element's parent, if it exists.
 
std::optional< SVGElementfirstChild () const
 Get the first child of this element, if it exists.
 
std::optional< SVGElementlastChild () const
 Get the last child of this element, if it exists.
 
std::optional< SVGElementpreviousSibling () const
 Get the previous sibling of this element, if it exists.
 
std::optional< SVGElementnextSibling () 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< SVGElementquerySelector (std::string_view selector)
 Find the first element in the tree that matches the given CSS selector.
 
const PropertyRegistrygetComputedStyle () const
 Get the computed CSS style of this element, after the CSS cascade.
 

Static Public Member Functions

static SVGRadialGradientElement Create (SVGDocument &document)
 Create a new "<radialGradient>" element.
 

Static Public Attributes

static constexpr ElementType Type = ElementType::RadialGradient
 Element type.
 
static constexpr std::string_view Tag {"radialGradient"}
 XML tag name, "<radialGradient>".
 

Protected Member Functions

 SVGRadialGradientElement (EntityHandle handle)
 Create an SVGRadialGradientElement wrapper from an entity.
 
- Protected Member Functions inherited from donner::svg::SVGGradientElement
 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.
 
Registryregistry () 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.
 

Static Protected Member Functions

static SVGRadialGradientElement CreateOn (EntityHandle handle)
 Internal constructor to create the element on an existing Entity.
 
- Static Protected Member Functions inherited from donner::svg::SVGElement
static EntityHandle CreateEntity (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.
 

Friends

class parser::SVGParserImpl
 

Additional Inherited Members

- Protected Attributes inherited from donner::svg::SVGElement
EntityHandle handle_
 The underlying ECS Entity for this element, which holds all data.
 

Detailed Description

DOM object for a "<radialGradient>" element.

<radialGradient id="MyGradient">
<stop offset="0%" stop-color="blue" />
<stop offset="100%" stop-color="yellow" />
</radialGradient>

To reference it with a fill:

<rect fill="url(#MyGradient)" width="300" height="300" />

To control the shape of the radial gradient, use the cx, cy, r, fx, fy, and fr attributes, which defines two circles representing the start and end of the gradient, the focal point and the outer circle. If the focal point is not specified (fx, fy, and fr), the focal point defaults to the position of the outer circle (cx and cy) with radius 0.

cx,cy r fx,fy fr

Attribute Default Description
cx 50% Center X coordinate, for the outer circle.
cy 50% Center Y coordinate, for the outer circle.
r 50% Radius of the outer circle.
fx cx Focal point X coordinate.
fy cy Focal point Y coordinate.
fr 0 Focal point radius.
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: <radialGradient id="MyGradient" href="#MyGradient2" />
See also
SVGLinearGradientElement, SVGStopElement

Member Function Documentation

◆ Create()

static SVGRadialGradientElement donner::svg::SVGRadialGradientElement::Create ( SVGDocument & document)
inlinestatic

Create a new "<radialGradient>" element.

Parameters
documentContaining document.

◆ CreateOn()

SVGRadialGradientElement donner::svg::SVGRadialGradientElement::CreateOn ( EntityHandle handle)
staticprotected

Internal constructor to create the element on an existing Entity.

Parameters
handleEntity handle.

◆ cx()

std::optional< Lengthd > donner::svg::SVGRadialGradientElement::cx ( ) const

Get the center X coordinate, for the outer circle.

Note that at render-time, this will default to 50% if not set.

◆ cy()

std::optional< Lengthd > donner::svg::SVGRadialGradientElement::cy ( ) const

Get the center Y coordinate, for the outer circle.

Note that at render-time, this will default to 50% if not set.

◆ fr()

std::optional< Lengthd > donner::svg::SVGRadialGradientElement::fr ( ) const

Get the focal point radius.

Note that at render-time, this will default to 0 if not set.

◆ fx()

std::optional< Lengthd > donner::svg::SVGRadialGradientElement::fx ( ) const

Get the focal point X coordinate.

Note that at render-time, this will default to cx() if not set.

◆ fy()

std::optional< Lengthd > donner::svg::SVGRadialGradientElement::fy ( ) const

Get the focal point Y coordinate.

Note that at render-time, this will default to cy() if not set.

◆ r()

std::optional< Lengthd > donner::svg::SVGRadialGradientElement::r ( ) const

Get the radius of the outer circle.

Note that at render-time, this will default to 50% if not set.

◆ setCx()

void donner::svg::SVGRadialGradientElement::setCx ( std::optional< Lengthd > value)

Set the center X coordinate, for the outer circle.

Parameters
valueCoordinate value, or std::nullopt to remove the attribute.

◆ setCy()

void donner::svg::SVGRadialGradientElement::setCy ( std::optional< Lengthd > value)

Set the center Y coordinate, for the outer circle.

Parameters
valueCoordinate value, or std::nullopt to remove the attribute.

◆ setFr()

void donner::svg::SVGRadialGradientElement::setFr ( std::optional< Lengthd > value)

Set the focal point radius.

Parameters
valueRadius value, or std::nullopt to remove the attribute.

◆ setFx()

void donner::svg::SVGRadialGradientElement::setFx ( std::optional< Lengthd > value)

Set the focal point X coordinate.

Parameters
valueCoordinate value, or std::nullopt to remove the attribute.

◆ setFy()

void donner::svg::SVGRadialGradientElement::setFy ( std::optional< Lengthd > value)

Set the focal point Y coordinate.

Parameters
valueCoordinate value, or std::nullopt to remove the attribute.

◆ setR()

void donner::svg::SVGRadialGradientElement::setR ( std::optional< Lengthd > value)

Set the radius of the outer circle.

Parameters
valueRadius value, or std::nullopt to remove the attribute.

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