A utility class that holds all properties of a Stroke.
Remarks
The stroke that is defined by instances of this type can be applied to an SVG element using either the static helper setStroke 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.
The strings applying to this scheme are converted to Strokes:
'[thickness] [type] color'
thickness = thickness in px|thin|medium|thick
type = solid|dashed|dotted
color = CSS color strings
Valid color strings are the same as for Color. Square brackets mark optional declarations.
Examples:
'3px dashed blue'
'thick blue'
'dotted blue'
Type Details
- yfiles module
- view-component
- yfiles-umd modules
- All view modules
- Legacy UMD name
- yfiles.view.Stroke
See Also
Constructors
Initializes a new instance of the Stroke class using the given fill and thickness.
Parameters
A map of options to pass to the method.
- fill - Fill
- The fill.
- thickness - number
- The thickness.
- lineCap - LineCap
The dash cap. This option sets the lineCap property on the created object.
- lineJoin - LineJoin
The line join property. This option sets the lineJoin property on the created object.
- dashStyle - DashStyle
- miterLimit - number
The miter limit. This option sets the miterLimit property on the created object.
Initializes a new instance of the Stroke class using the given rgba values and thickness.
Remarks
Parameters
A map of options to pass to the method.
- r - number
- The red value.
- g - number
- The green value.
- b - number
- The blue value.
- a - number
- The alpha value, 255 by default.
- thickness - number
- The thickness, 1 by default.
- fill - Fill
- lineCap - LineCap
The dash cap. This option sets the lineCap property on the created object.
- lineJoin - LineJoin
The line join property. This option sets the lineJoin property on the created object.
- dashStyle - DashStyle
- miterLimit - number
The miter limit. This option sets the miterLimit property on the created object.
Properties
Gets or sets the dash style for the Stroke.
Remarks
The visual appearance of the 'dashes' and 'gaps' specified by this property depends on the value of the property lineCap, too.
The predefined dash styles are designed for dash caps that extend into the 'gaps' like SQUARE and ROUND. With FLAT, the dashes might not look like expected, for example DOT will not be visible at all. Since FLAT is the default value, you should explicitly set another value in this case.
Gets or sets the dash cap.
Gets or sets the line join property.
Methods
Assigns the stroke defined by this instance to the given SVG element
.
Remarks
null
strokes. 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 memberwiseClone or this in case this instance is already frozen.
Static Methods
Creates a Stroke instance from the given stroke-like object by performing automatic type conversion.
Sets the Stroke on a given SVG element as the stroke.
Remarks
stroke
is null
.Parameters
A map of options to pass to the method.
- stroke - Stroke
- The stroke that should be applied. If
null
, the element's stroke is removed. - element - SVGElement
- The element whose stroke should be set.
- context - ICanvasContext
- The context to use for managing possible
defs
entries.