WanaPlan

API Docs for: 2.7.0
Show:

wnp.Symbols2D

Module: Helpers
Parent Module: Wanaplan

Summary

Draw methods for standard 2D symbols

Constructor

wnp.Symbols2D

Syntax

wnp.Symbols2D

(
  • core
)

Summary

Parameters:

  • core Core

    The main engine.

Methods

_drawAllSymbols

Syntax

_drawAllSymbols

(
  • ctx
)
private

Summary

Debug function to draw all symbols

Parameters:

  • ctx CanvasRenderingContext2D

    The canvas' context.

drawAngle

Syntax

drawAngle

(
  • ctx
  • pos
  • [zoom=1]
  • radius
  • angle0
  • angle1
  • clockwise
)

Summary

Draws an angle.

Parameters:

  • ctx CanvasRenderingContext2D

    The context.

  • pos Object

    Position {x: ?, y: ?}.

  • [zoom=1] Number optional

    The zoom level. Not taken into account for now.

  • radius Number

    Radius of the arc symbol.

  • angle0 Number

    Angle 0, based on the x-axis.

  • angle1 Number

    Angle 1, based on the x-axis.

  • clockwise Boolean

    Direction of the arc.

drawArc

Syntax

drawArc

(
  • ctx
  • point1
  • cp
  • point2
)

Summary

Draws an arc set by a control point.

Parameters:

  • ctx CanvasRenderingContext2D

    The context.

  • point1 Object

    Position of the first point {x: ?, y: ?}.

  • cp Object

    Position of the control point {x: ?, y: ?}.

  • point2 Object

    Position of the second point {x: ?, y: ?}.

drawArrows

Syntax

drawArrows

(
  • ctx
  • pos
  • arrows
  • distance
  • angle
)
private

Summary

Draws arrows.

Parameters:

  • ctx CanvasRenderingContext2D

    The canvas' context.

  • pos Object

    Position {x: ?, y: ?}.

  • arrows Array

    List of arrows to draw [up, left, down, right]`.

  • distance Number

    Distance des flèches par rapport au centre définit par pos.

  • angle Number

    (optionnel) Rotation angle.

drawCancelGrip

Syntax

drawCancelGrip

(
  • ctx
  • pos
  • arrows
  • [angle=0]
)

Summary

Draws a grip with a cancel icon at the end.

Parameters:

  • ctx CanvasRenderingContext2D

    The context.

  • pos Object

    Position {x: ?, y: ?}.

  • arrows Array

    List of arrows to draw [up, left, down, right]`.

  • [angle=0] Number optional

    Rotation angle.

drawCheckGrip

Syntax

drawCheckGrip

(
  • ctx
  • pos
  • arrows
  • [angle=0]
)

Summary

Draws a grip with a check icon at the end.

Parameters:

  • ctx CanvasRenderingContext2D

    The context.

  • pos Object

    Position {x: ?, y: ?}.

  • arrows Array

    List of arrows to draw [up, left, down, right]`.

  • [angle=0] Number optional

    Rotation.

drawCursorCheck

Syntax

drawCursorCheck

(
  • ctx
  • pos
)

Summary

Draws a check icon.

Parameters:

  • ctx CanvasRenderingContext2D

    The context.

  • pos Object

    Position {x: ?, y: ?}.

drawGrip

Syntax

drawGrip

(
  • ctx
  • pos
  • arrows
  • [angle=0]
)

Summary

Draws a grip.

Parameters:

  • ctx CanvasRenderingContext2D

    The context.

  • pos Object

    Position {x: ?, y: ?}.

  • arrows Array

    List of arrows to draw [up, left, down, right]`.

  • [angle=0] Number optional

    Rotation.

drawGripSegment

Syntax

drawGripSegment

(
  • ctx
  • point1
  • point2
  • arrows
  • arrows
  • [angle=0]
)

Summary

Draws a segment with grips.

Parameters:

  • ctx CanvasRenderingContext2D

    The context.

  • point1 Object

    Position of the first point {x: ?, y: ?}.

  • point2 Object

    Position of the second point {x: ?, y: ?}.

  • arrows Array

    List of arrows to draw for the first grip [up, left, down, right]`.

  • arrows Array

    List of arrows to draw for the second grip [up, left, down, right]`.

  • [angle=0] Number optional

    Rotation.

drawMeasure

Syntax

drawMeasure

(
  • ctx
  • point1
  • point2
  • text
  • [color=wnp.Symbols2D.COLOR_ANNOTATION]
)

Summary

Draws a measure.

Parameters:

  • ctx CanvasRenderingContext2D

    The context.

  • point1 Object

    Position of the first point {x: ?, y: ?}.

  • point2 Object

    Position of the second point {x: ?, y: ?}.

  • text String

    Text displayed at the center of the measure.

  • [color=wnp.Symbols2D.COLOR_ANNOTATION] String optional

    Color.

drawPoint

Syntax

drawPoint

(
  • ctx
  • pos
)

Summary

Draws a simple point.

Parameters:

  • ctx CanvasRenderingContext2D

    The context.

  • pos Object

    Position {x: ?, y: ?}.

drawPointHover

Syntax

drawPointHover

(
  • ctx
  • pos
  • [zoom=1]
)

Summary

Draws a point when it is hovered.

Parameters:

  • ctx CanvasRenderingContext2D

    The context.

  • pos Object

    Position {x: ?, y: ?}.

  • [zoom=1] Number optional

    The zoom level.

drawSegment

Syntax

drawSegment

(
  • ctx
  • point1
  • point2
)

Summary

Draws a segment.

Parameters:

  • ctx CanvasRenderingContext2D

    The context.

  • point1 Object

    Position of the first point {x: ?, y: ?}.

  • point2 Object

    Position of the second point {x: ?, y: ?}.

Properties

COLOR_ACTIVE_FILL

Syntax

COLOR_ACTIVE_FILL

String

Summary

COLOR_ACTIVE_FILL

Default: "rgba(137, 184, 8, 0.2)"

COLOR_ACTIVE_LARGEZONE_FILL

Syntax

COLOR_ACTIVE_LARGEZONE_FILL

String

Summary

COLOR_ACTIVE_LARGEZONE_FILL

Default: "rgba(137, 137, 137, 0.5)"

COLOR_ACTIVE_STROKE

Syntax

COLOR_ACTIVE_STROKE

String

Summary

COLOR_ACTIVE_STROKE

Default: "#89B808"

COLOR_ACTIVE_STROKE_DARKER

Syntax

COLOR_ACTIVE_STROKE_DARKER

String

Summary

COLOR_ACTIVE_STROKE_DARKER

Default: "#6C9104"

COLOR_ANNOTATION

Syntax

COLOR_ANNOTATION

String

Summary

COLOR_ANNOTATION

Default: "#888"

COLOR_BACKGROUND

Syntax

COLOR_BACKGROUND

String

Summary

COLOR_BACKGROUND

Default: "#FAFAFA"

COLOR_INACTIVE_FILL

Syntax

COLOR_INACTIVE_FILL

String

Summary

COLOR_INACTIVE_FILL

Default: "rgba(90, 119, 119, 0.1)"

COLOR_INACTIVE_STROKE

Syntax

COLOR_INACTIVE_STROKE

String

Summary

COLOR_INACTIVE_STROKE

Default: "#777777"