SceneElement Class
An element of a Scene.
public abstract class SceneElementProperties
| Name | Description |
|---|---|
| BlendMode | Gets or sets how the element is blended with what is drawn under it. The default is SceneBlendMode.Normal. |
| ClippingPath | Gets or sets the shapes and texts outside of which the element is not drawn, as the SVG clip-path property, or null for none. |
| CssClass | Gets or sets the CSS class of the element in the SVG output. |
| DataAttributes | Gets the data-* attributes of the element in the SVG output, by name without the data- prefix. Scripts of a web page read them with element.dataset. Set them with SceneElement.SetDataAttribute. |
| Filter | Gets or sets the effect applied to what the element draws, such as a blur or a drop shadow, or null for none. |
| Hyperlink | Gets or sets the address the element links to, or null for none. The SVG output wraps the element in an a element, the PDF output adds a link over what it draws (absolute addresses only), and an image ignores it. |
| Id | Gets or sets the identifier of the element in the SVG output (its id attribute), or null for none: a script or a style sheet of a web page finds the element with it. The other renderers ignore it. |
| Mask | Gets or sets the opacity mask of the element, or null for none. |
| Opacity | Gets or sets the opacity of the element, from 0 to 1. |
| Tooltip | Gets or sets the text shown when hovering the element (an SVG title). |
| Transform | Gets or sets the transform of the element, or null for none. For a group, it transforms its children. |
BlendMode
SceneElement.csGets or sets how the element is blended with what is drawn under it. The default is SceneBlendMode.Normal.
public SceneBlendMode BlendMode { get; set; }Property value
ClippingPath
SceneElement.csGets or sets the shapes and texts outside of which the element is not drawn, as the SVG clip-path property, or null for none.
public SceneClipPath? ClippingPath { get; set; }Property value
Remarks
The clipping path is in the coordinates of the parent of the element, as SceneElement.Mask: outside of the SceneElement.Transform of the element. It applies after the SceneElement.Filter and before the mask, as in SVG.
CssClass
SceneElement.csDataAttributes
SceneElement.csGets the data-* attributes of the element in the SVG output, by name without the data- prefix. Scripts of a web page read them with element.dataset. Set them with SceneElement.SetDataAttribute.
public IReadOnlyDictionary<string, string> DataAttributes { get; }Property value
Filter
SceneElement.csGets or sets the effect applied to what the element draws, such as a blur or a drop shadow, or null for none.
public SceneFilter? Filter { get; set; }Property value
Remarks
PDF has no filters: the PDF renderer throws NotSupportedException for a scene that has one.
Hyperlink
SceneElement.csGets or sets the identifier of the element in the SVG output (its id attribute), or null for none: a script or a style sheet of a web page finds the element with it. The other renderers ignore it.
public string? Id { get; set; }Property value
Exceptions
ArgumentException- The value is not a valid identifier (
SceneElement.IsValidId).
Remarks
The identifiers of the elements of a scene must be different: SvgSceneRenderer throws InvalidOperationException when two elements have the same one. The identifiers the renderer generates (of the gradients, the clip paths, ...) avoid them.
Mask
SceneElement.csGets or sets the opacity mask of the element, or null for none.
public SceneMask? Mask { get; set; }Property value
Opacity
SceneElement.csTooltip
SceneElement.csTransform
SceneElement.csGets or sets the transform of the element, or null for none. For a group, it transforms its children.
public SceneTransform? Transform { get; set; }Property value
Remarks
The element is drawn as if it were the only child of a group with this transform: its clips, its mask, its filter, its opacity and its hyperlink are in the coordinates of its parent, around what it draws. The rotation of a text (SceneText.Rotation) applies before the transform.
Methods
| Name | Description |
|---|---|
| GetBounds(Func<SceneText, SceneBounds?>, bool) | Gets a rectangle that contains what the element draws, in the coordinates of its parent, or null when it draws nothing, for a renderer that places what it draws: a filter region, a link, a layer. |
| IsValidDataAttributeName(string?) | Indicates whether a name is a valid name of a data-* attribute: lowercase ASCII letters, digits, hyphens, underscores and dots, without the data- prefix. |
| IsValidId(string?) | Indicates whether a value is a valid identifier (SceneElement.Id): an ASCII letter, then ASCII letters, digits, hyphens, underscores and dots. |
| SetDataAttribute(string, string?) | Sets a data-* attribute of the element in the SVG output, or removes it. |
| ThrowIfInvalidDataAttributeName(string, string) | Throws when a name is not a valid name of a data-* attribute. |
GetBounds(Func<SceneText, SceneBounds?>, bool)
SceneElement.csGets a rectangle that contains what the element draws, in the coordinates of its parent, or null when it draws nothing, for a renderer that places what it draws: a filter region, a link, a layer.
public SceneBounds? GetBounds(Func<SceneText, SceneBounds?> measureText, bool applyClips = true)Parameters
measureTextFunc<SceneText, SceneBounds?>- Gives the rectangle of a text before its rotation, in the coordinates of its parent, or
nullwhen it draws nothing: the size of a text depends on the fonts of the renderer. It is not called for a text on a path (SceneText.Path), whose rectangle is the one of its path enlarged by the size of its font. applyClipsbool- Whether the clips apply (
SceneGroup.Clip,SceneGroup.ClipPath,SceneElement.ClippingPath). The filter of an element applies before its clips: the region of its filter is the rectangle without them.
Returns
SceneBounds? The rectangle, or null.
Remarks
The rectangle contains the strokes, with their joins and their caps, and the blurs and the shadows of the children; not the filter of the element itself. A group applies its transform, and its clips unless applyClips is false.
IsValidDataAttributeName(string?)
SceneElement.csIsValidId(string?)
SceneElement.csIndicates whether a value is a valid identifier (SceneElement.Id): an ASCII letter, then ASCII letters, digits, hyphens, underscores and dots.
SetDataAttribute(string, string?)
SceneElement.csSets a data-* attribute of the element in the SVG output, or removes it.
Parameters
namestring- The name of the attribute without the
data-prefix: lowercase ASCII letters, digits, hyphens, underscores and dots. valuestring?- The value, or
nullto remove the attribute.
Exceptions
ArgumentExceptionnameis empty or contains another character.
ThrowIfInvalidDataAttributeName(string, string)
SceneElement.csThrows when a name is not a valid name of a data-* attribute.
Parameters
Exceptions
ArgumentExceptionnameis empty or contains another character.ArgumentNullExceptionnameisnull.