module:Path

Path class
path demo

Constructor

new module:Path(positionDefinition, instructions, isClosedopt, optionsopt)

Path constructor

Parameters:
NameTypeAttributesDefaultDescription
positionDefinitionPositionDefinition

Starting position of the Path

instructionsArray.<Instruction> | String

Set of instructions to follow to draw it

isClosedBoolean<optional>
true

Should the path close itself (add a line to the starting position)

optionsComponentOptions | LineOptions<optional>

Drawing options

Extends

Methods

(static) arcTo(position, angle, magicRatio, clockwiseopt) → {Instruction}

Try to approximate an arc between two points

Parameters:
NameTypeAttributesDefaultDescription
positionPositionDefinition

Any position

angleNumber

Arc angle in ratio of a full circle (should be less than 0.5)

magicRatioNumber

Control points "openness" ratio

clockwiseBoolean<optional>
true

Should the arc be clockwise or not

Returns:
Type: 
Instruction

(static) bezierTo(position, firstControlPoint, secondControlPoint) → {Instruction}

Draw a bezier curve to a position

Parameters:
NameTypeDescription
positionPositionDefinition

Any position

firstControlPointPositionDefinition

First point to control the curve

secondControlPointPositionDefinition

Second point to control the curve

Returns:
Type: 
Instruction

(static) from(definition) → {Path}

Parameters:
NameTypeDescription
definitionObject

Path definition

Returns:
Type: 
Path

(static) halfTo(position, clockwiseopt) → {Instruction}

Draw an quarter circle arc to a position

Parameters:
NameTypeAttributesDefaultDescription
positionPositionDefinition

Any position

clockwiseBoolean<optional>
true

Should the arc be clockwise or not

Returns:
Type: 
Instruction

(static) lineTo(position) → {Instruction}

Draw a line to a position

Parameters:
NameTypeDescription
positionPositionDefinition

Any position

Returns:
Type: 
Instruction

(static) moveTo(position) → {Instruction}

Move the pencil without drawing

Parameters:
NameTypeDescription
positionPositionDefinition

Any position

Returns:
Type: 
Instruction

(static) quadTo(position, controlPoint) → {Instruction}

Draw a quadratic curve to a position

Parameters:
NameTypeDescription
positionPositionDefinition

Any position

controlPointPositionDefinition

Point that control the curve

Returns:
Type: 
Instruction

(static) quarterTo(position, clockwiseopt) → {Instruction}

Draw an quarter circle arc to a position

Parameters:
NameTypeAttributesDefaultDescription
positionPositionDefinition

Any position

clockwiseBoolean<optional>
true

Should the arc be clockwise or not

Returns:
Type: 
Instruction

(static) sinTo(position, nbSins, sinsHeight) → {Instruction}

Parameters:
NameTypeDescription
positionPositionDefinition

Any position

nbSinsNumber

Number of sinusoid to draw

sinsHeightNumber

Height of the sinusoid

Returns:
Type: 
Instruction

(static) splineThrough(points, tensionopt) → {Instruction}

Parameters:
NameTypeAttributesDescription
pointsArray.<PositionDefinition>

Any set of positions

tensionNumber<optional>

Ratio of tension

Returns:
Type: 
Instruction

(static) waveTo(position, nbWaves) → {Instruction}

Parameters:
NameTypeDescription
positionPositionDefinition

Any position

nbWavesNumber

Number of waves to draw

Returns:
Type: 
Instruction

trace(path) → {Path}

Draw the path

Parameters:
NameTypeDescription
pathPath2D

Current drawing path

Returns:

Itself

Type: 
Path