Stroke

Source: AWT.js:502

Contains properties used to draw lines in HTML canvas elements.


Constructor

new Stroke( lineWidth?: number, lineCap?: string, lineJoin?: string, miterLimit?: number, ): Stroke

Stroke constructor

Parameters

  • lineWidth (number, optional, default: 1) — The line width of the stroke
  • lineCap (string, optional, default: "'butt'") — The line ending type. Possible values are: butt, round
    and square.
  • lineJoin (string, optional, default: "'miter'") — The type of drawing used when two lines join. Possible
    values are: round, bevel and miter.
  • miterLimit (number, optional, default: 10) — The ratio between the miter length and half lineWidth.

Instance Methods

getAttributes(): object

Gets a object with the basic attributes needed to rebuild this instance excluding functions,
parent references, constants and also attributes retaining the default value.
The resulting object is commonly usued to serialize elements in JSON format.

Returns

  • object

setAttributes(data: object): module:AWT.Stroke

Reads the properties of this Stroke from a data object

Parameters

  • data (object) — The data object to be parsed

Returns

setStroke( ctx: external:CanvasRenderingContext2D, ): external:CanvasRenderingContext2D

Sets the properties of this stroke to a CanvasRenderingContext2D

Parameters

Returns

Instance Fields

lineWidth: number

The line width

lineCap: string

The line ending type (butt, round or square)

lineJoin: string

The drawing used when two lines join (round, bevel or miter)

miterLimit: number

Ratio between the miter length and half lineWidth