module:Path

module:Path

Path class
path demo

Constructor

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

Path constructor

Parameters:
Name Type Attributes Default Description
positionDefinition PositionDefinition

Starting position of the Path

instructions Array.<Instruction> | String

Set of instructions to follow to draw it

isClosed Boolean <optional>
true

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

options ComponentOptions | LineOptions <optional>

Drawing options

Extends

Methods

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

Try to approximate an arc between two points

Parameters:
Name Type Attributes Default Description
position PositionDefinition

Any position

angle Number

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

magicRatio Number

Control points "openness" ratio

clockwise Boolean <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:
Name Type Description
position PositionDefinition

Any position

firstControlPoint PositionDefinition

First point to control the curve

secondControlPoint PositionDefinition

Second point to control the curve

Returns:
Type
Instruction

# (static) from(definition) → {Path}

Parameters:
Name Type Description
definition Object

Path definition

Returns:
Type
Path

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

Draw an quarter circle arc to a position

Parameters:
Name Type Attributes Default Description
position PositionDefinition

Any position

clockwise Boolean <optional>
true

Should the arc be clockwise or not

Returns:
Type
Instruction

# (static) lineTo(position) → {Instruction}

Draw a line to a position

Parameters:
Name Type Description
position PositionDefinition

Any position

Returns:
Type
Instruction

# (static) moveTo(position) → {Instruction}

Move the pencil without drawing

Parameters:
Name Type Description
position PositionDefinition

Any position

Returns:
Type
Instruction

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

Draw a quadratic curve to a position

Parameters:
Name Type Description
position PositionDefinition

Any position

controlPoint PositionDefinition

Point that control the curve

Returns:
Type
Instruction

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

Draw an quarter circle arc to a position

Parameters:
Name Type Attributes Default Description
position PositionDefinition

Any position

clockwise Boolean <optional>
true

Should the arc be clockwise or not

Returns:
Type
Instruction

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

Parameters:
Name Type Description
position PositionDefinition

Any position

nbSins Number

Number of sinusoid to draw

sinsHeight Number

Height of the sinusoid

Returns:
Type
Instruction

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

Parameters:
Name Type Attributes Description
points Array.<PositionDefinition>

Any set of positions

tension Number <optional>

Ratio of tension

Returns:
Type
Instruction

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

Parameters:
Name Type Description
position PositionDefinition

Any position

nbWaves Number

Number of waves to draw

Returns:
Type
Instruction

# trace(path) → {Path}

Draw the path

Parameters:
Name Type Description
path Path2D

Current drawing path

Returns:

Itself

Type
Path