AWT. PathStroke

PathStroke is the basic component of module:AWT.Path objects

Constructor

new PathStroke(type, points)

PathStroke constructor

Parameters:
NameTypeDescription
typestring

The type of stroke. Possible values are: M (move to), L (line to),
Q (quadratic to), B (bezier to) and X (close path).

pointsArray.<module:AWT.Point>

The array of module:AWT.Point objects used in this Stroke.

Members

points :Array.<module:AWT.Point>

The array of points used by this stroke. Can be null.

Type:

type :string

The Stroke type. Possible values are: M (move to), L (line to), Q (quadratic to),
B (bezier to) and X (close path).

Type:
  • string

Methods

clone() → {module:AWT.PathStroke}

Clones this PathStroke

Returns:
Type: 
module:AWT.PathStroke

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:
  • The resulting object, with minimal attrributes
Type: 
object

getEnclosingPoints(from) → {Array.<module:AWT.Point>}

Gets the set of points that will be included as a vertexs on the owner's shape
enclosing polygon.

Parameters:
NameTypeDescription
frommodule:AWT.Point

The starting point for this stroke

Returns:
Type: 
Array.<module:AWT.Point>

moveBy(delta)

Increments or decrements by delta the x and y coordinates of all points

Parameters:
NameTypeDescription
deltaPoint | Dimension

The amount to add to the x and y
coordinates of each point.

multBy(delta)

Multiplies each point coordinates by the x and y (or w and h) values of the
passed module:AWT.Point or Dimension.

Parameters:
NameTypeDescription
deltaPoint | Dimension

stroke(ctx)

Draws this PathStroke in the provided HTML canvas context

Parameters:
NameTypeDescription
ctxexternal:CanvasRenderingContext2D

The HTML canvas 2D rendering context

(static) getCubicPoints(p0, p1, p2, p3, numPointsopt) → {Array.<module:AWT.Point>}

Calculates some of the points included in a cubic Bézier (curve with two control points)
The number of points being calculated is defined in Utils.settings.BEZIER_POINTS

Parameters:
NameTypeAttributesDescription
p0module:AWT.Point

Starting point of the cubic Bézier curve

p1module:AWT.Point

First control point

p2module:AWT.Point

Second control point

p3module:AWT.Point

Ending point

numPointsnumber<optional>

The number of intermediate points to calculate. When not defined,
the value will be obtained from module:Utils.settings.BEZIER_POINTS.

Returns:
  • Array with some intermediate points from the resulting Bézier curve
Type: 
Array.<module:AWT.Point>

(static) getQuadraticPoints(p0, p1, p2, numPointsopt) → {Array.<module:AWT.Point>}

Calculates some of the points included in a quadratic Bézier curve
The number of points being calculated is defined in Utils.settings.BEZIER_POINTS

Parameters:
NameTypeAttributesDescription
p0module:AWT.Point

Starting point of the quadratic Bézier curve

p1module:AWT.Point

Control point

p2module:AWT.Point

Ending point

numPointsnumber<optional>

The number of intermediate points to calculate. When not defined,
the value will be obtained from module:Utils.settings.BEZIER_POINTS.

Returns:
  • Array with some intermediate points from the resulting Bézier curve
Type: 
Array.<module:AWT.Point>