Constructor
new Stroke(widthopt, backgroundopt, alignmentopt, capopt, joinopt, miterLimitopt, dashSizeopt, dashGapSizeopt, dashPhaseopt)
Create an instance of a Stroke object.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
width | number | <optional> | 1 | Specifies the thickness of the line. Default is 1 pixel thick. |
background | string | <optional> | #000000 | Stroke color. e.g. #008800. Setting gradients and a background image will be also possible in future. |
alignment | Stroke. | <optional> | Where stroke line is drawn: outside of shape, on the edge, or inside. Default is Center. Valid values: Stroke.Alignment.Outside, Stroke.Alignment.Center, Stroke.Alignment.Inside. | |
cap | Stroke. | <optional> | Defines the end cap style of the line. Default is Square. Valid values: Stroke.Cap.Square, Stroke.Cap.Butt, Stroke.Cap.Round. | |
join | Stroke. | <optional> | Specifies the line join style. Default is Miter. Valid values: Stroke.Join.Miter, Stroke.Join.Bevel, Stroke.Join.Round. | |
miterLimit | number | <optional> | 10 | Applicable when join is set to JOIN_MITER. It controls the maximum miter length. If the miter length exceeds this limit, the join is beveled instead. |
dashSize | number | <optional> | null | Size of a dash in a dash pattern, |
dashGapSize | number | <optional> | null | Size of gaps between dashes in dash pattern |
dashPhase | number | <optional> | 0 | Specifies the starting point of the dash pattern. It determines where in the dash pattern the line starts. A positive value shifts the pattern to the right, and a negative value shifts it to the left. |
Classes
Members
(readonly) Alignment :number
Static enum for stroke alignment. Defines how the stroke is positioned relative to the shape’s outline.
- number
| Name | Type | Description |
|---|---|---|
Inside | number | Stroke fully inside the shape path. |
Center | number | Stroke centered on the shape path. |
Outside | number | Stroke fully outside the shape path. |
Stroke.Alignment.Outside(readonly) Cap :number
Static enum for stroke cap styles. Defines how the ends of open subpaths are drawn.
- number
| Name | Type | Description |
|---|---|---|
Butt | number | Flat end, no extension beyond the end point. |
Round | number | Rounded end with a half-circle extension. |
Square | number | Flat end extended by half the line width. |
Stroke.Cap.Round(readonly) Join :number
Static enum for stroke join styles. Defines how two connected line segments are joined.
- number
| Name | Type | Description |
|---|---|---|
Miter | number | Sharp corner with extended outer edges. |
Round | number | Rounded corner with a circular arc. |
Bevel | number | Flattened corner with a straight cut. |
Stroke.Join.BevelMethods
toObject() → {object}
Convert Stroke to JSON Object to be able to store it or modify it and convert back to the Stroke object using Stroke.fromObject(stroke).
Returns an object holding all properties of this Stroke object.
- Type:
- object
(static) fromObject(stroke) → {Stroke}
Restore Stroke from JSON object that represents all properties of the Stroke object.
| Name | Type | Description |
|---|---|---|
stroke | object | JSON object that holds properties of a Stroke object. It can be generated by stroke.toObject(). |
Returns an instance of a new Stroke object.
- Type:
- Stroke