Table of Contents

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

variableName string

The 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

variableName string

The CSS custom property name, including the leading '--' (e.g. --my-color).

fallbackServer SvgPaintServer

The 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

SvgPaintServer

VariableName

Gets or sets the CSS custom property name, including the leading '--'.

public string VariableName { get; set; }

Property Value

string

Methods

DeepCopy()

public override SvgElement DeepCopy()

Returns

SvgElement

DeepCopy<T>()

public override SvgElement DeepCopy<T>() where T : SvgElement, new()

Returns

SvgElement

Type Parameters

T

Equals(object)

Determines whether the specified object is equal to the current object.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

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

styleOwner SvgVisualElement

The owner SvgVisualElement.

renderer ISvgRenderer

The renderer object.

opacity float

The opacity of the brush.

forStroke bool

Not used.

Returns

Brush

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

element SvgElement

Returns

SvgPaintServer

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()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.