Class SvgCssVariablePaintServer
- Namespace
- Svg
- Assembly
- Svg.dll
A paint server that resolves a CSS custom property (CSS variable) referenced via the
var() function, e.g. var(--my-color) or var(--my-color, red).
The variable is looked up by walking the element's ancestor chain at render time,
checking every style specificity level so that properties defined in external
stylesheets are found as well as inline ones.
public class SvgCssVariablePaintServer : SvgPaintServer, ISvgTransformable, ICloneable, ISvgNode
- Inheritance
-
SvgCssVariablePaintServer
- Implements
- Inherited Members
- Extension Methods
Constructors
SvgCssVariablePaintServer()
Initialises a new, empty instance (required by DeepCopy<T>()).
public SvgCssVariablePaintServer()
SvgCssVariablePaintServer(string)
Initialises a new instance with the given variable name and no fallback.
public SvgCssVariablePaintServer(string variableName)
Parameters
variableNamestringThe CSS custom property name, including the leading '
--' (e.g.--my-color).
SvgCssVariablePaintServer(string, SvgPaintServer)
Initialises a new instance with the given variable name and fallback.
public SvgCssVariablePaintServer(string variableName, SvgPaintServer fallbackServer)
Parameters
variableNamestringThe CSS custom property name, including the leading '
--' (e.g.--my-color).fallbackServerSvgPaintServerThe paint server to use when the variable cannot be resolved, or
null.
Properties
FallbackServer
Gets the fallback SvgPaintServer used when the variable cannot be
resolved, or null if no fallback was specified.
public SvgPaintServer FallbackServer { get; }
Property Value
VariableName
Gets or sets the CSS custom property name, including the leading '--'.
public string VariableName { get; set; }
Property Value
Methods
DeepCopy()
public override SvgElement DeepCopy()
Returns
DeepCopy<T>()
public override SvgElement DeepCopy<T>() where T : SvgElement, new()
Returns
Type Parameters
T
Equals(object)
Determines whether the specified object is equal to the current object.
public override bool Equals(object obj)
Parameters
objobjectThe object to compare with the current object.
Returns
GetBrush(SvgVisualElement, ISvgRenderer, float, bool)
Gets a Brush representing the current paint server.
public override Brush GetBrush(SvgVisualElement styleOwner, ISvgRenderer renderer, float opacity, bool forStroke = false)
Parameters
styleOwnerSvgVisualElementThe owner SvgVisualElement.
rendererISvgRendererThe renderer object.
opacityfloatThe opacity of the brush.
forStrokeboolNot used.
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
Resolve(SvgElement)
Resolves the CSS custom property by walking element's ancestor
chain (self included) and returns the first SvgPaintServer the value
maps to. Falls back to FallbackServer (or None)
when the property is not defined anywhere in the hierarchy.
public SvgPaintServer Resolve(SvgElement element)
Parameters
elementSvgElement
Returns
Remarks
Circular variable references (e.g. --a: var(--a)) are not detected and will
cause a StackOverflowException. Such declarations are invalid per the
CSS specification and the variable is treated as unset by conforming browsers.
ToString()
public override string ToString()