Represents any object that fills an area.
Remarks
The fill that is defined by instances of this type can be applied to an SVG element using either the static helper setFill or the instance method applyTo.
This is a convertible type that can be used with the following notation(s) in parameter lists, parameter objects or setters.
CSS color strings are converted to CssFills. For example:
'blue'
'#369'
'#336699'
'#369A',
'#336699AA'
'rgb(51, 102, 153)'
'rgba(51, 102, 153 / 0.5)'
'hsl(225, 98%, 60%)'
'hsla(225, 98%, 60% / 0.5)',
Additionally, SVG strings are supported. For example:
'none'
'url(#gradient)'
Arrays are converted to Color.
Type Details
- yFiles module
- view
See Also
Methods
Assigns the fill defined by this instance to the given SVG element
.
Remarks
If this Fill is a gradient and implements the ISvgDefsCreator interface, it will be added to the defs
section of the SVG document per the context
. The fill of the given element will be set to a reference to the gradient element.
This method is very similar in functionality to its static method counterpart setFill. However since this method is an instance method, it cannot be called on empty/null
fills. If you are unsure whether the reference actually points to an instance, use the static helper method instead.
Parameters
A map of options to pass to the method.
- element - SVGElement
- The element whose fill should be set.
- context - ICanvasContext
- The context.
See Also
Clones this instance by returning a memberwise clone, or by returning this
if this instance is frozen.
Static Methods
Creates a Fill instance from the given fill-like object by performing automatic type conversion.
Sets the Fill on a given SVG element as the fill.
Remarks
If this Fill is a gradient and implements the ISvgDefsCreator interface, it will be added to the defs
section of the SVG document per the context
. The fill of the given element will be set to a reference to the gradient element.
This method is very similar in functionality to its instance method counterpart applyTo. However, being static, it also allows for the case where the fill
is null
.
Parameters
A map of options to pass to the method.
- fill - Fill
- The fill that should be applied. If
null
, the element's fill is set tonone
. - element - SVGElement
- The SVG element whose fill should be set.
- context - ICanvasContext
- The context to use for managing possible
defs
entries.