API Docs for: 0.1.0
Show:

zerk.helper Class

Defined in: src/zerk/helper.js:1
Module: zerk

Helper

Global helper function library.

Methods

calculateDistance

(
  • x1
  • y1
  • x2
  • y2
)
Float

Calculates the distance between two positions

Parameters:

  • x1 Float

    First horizontal position

  • y1 Float

    First vertical position

  • x2 Float

    Second horizontal position

  • y2 Float

    Second vertical position

Returns:

Float: The distance

formatPercent

(
  • value
)
String

Formats a number in percent notation

Parameters:

  • value Float

Returns:

String: Percent notated number

fromMeter

(
  • value
)
Float

Converts meters into pixels

Parameters:

  • value Float

    Value in meters

Returns:

Float: Value in pixels

getCenterOfPolygon

(
  • polygon
)
Object

Returns the center position of given polygon

Parameters:

  • polygon Array

    Polygon array

Returns:

Object: Returns an object containing x and y position

isPolygonClockwise

(
  • polygon
)
Integer

Checks the clockwise order status of a polygon

Its assumed that:
- the polygon is closed
- the last point is not repeated
- the polygon is convex

Parameters:

  • polygon Array

    Polygon array

Returns:

Integer: Returns the following values: 0 = incomputable 1 = clockwise -1 = counterclockwise

random

(
  • min
  • max
)
Float

Returns a random number between min and max

Parameters:

  • min Float

    Minimum

  • max Float

    Maximum

Returns:

Float: Random number between min and max

rotatePosition

(
  • x
  • y
  • angle
)
Object

Rotate position at given angle

Parameters:

  • x Float

    Horizontal position

  • y Float

    Vertical position

  • angle Float

    Angle

Returns:

Object: Returns an object containing x and y position

round

(
  • value
  • decimals
)
Float

Rounds a number to given decimals

Parameters:

  • value Float

    Number

  • decimals Integer

    Number of decimals

Returns:

Float: Rounded number

toMeter

(
  • value
)
Float

Converts pixels into meters

Parameters:

  • value Float

    Value in pixels

Returns:

Float: Value in meters