API Docs for: v2.1.0
Show:

GLOBAL_METHODS Class

Module: Util

Global methods

Methods

cgsgClearContext

(
  • context
)

Wipes the canvas context

Parameters:

  • context CanvasRenderingContext2D

    context to render on

cgsgDetectCurrentExplorer

()

cgsgExist

(
  • o
)
Boolean

Parameters:

Returns:

Boolean:

true if the parameter !== null && !== undefined && (!isNaN(o) && isFinite(o))

cgsgFree

(
  • object
)

Free the given object and notify listeners with appropriate event.

Parameters:

  • object

cgsgGetCursorPositions

(
  • event
  • canvas
)
Array

Return the mouse or touch positions relative to the canvas

Parameters:

  • event Event

    a touch or mouse Event

  • canvas HTMLElement

    a handler to the Canvas element

Returns:

Array:

Array of CGSGPosition object

cgsgGetDisplayedViewportDimension

() CGSGDimension

Returns:

CGSGDimension:

a CGSGDimension as the viewport region

cgsgGetRealViewportDimension

() CGSGDimension

Returns:

CGSGDimension:

a CGSGDimension as the real viewport dimension

cgsgIterate

(
  • array
  • callback
)

Iterates the given array and, at each iteration, calls the given callback function. The loop stops if the callback function returns false.

Optimized loop is used here and should be prefer to other approaches, especially on old browser versions and IE.

Parameters:

cgsgIterateReverse

(
  • array
  • callback
)

Iterates the given array from the end to the beginning of the array. The loop stops if the callback function returns false.

Prefer to use this method for the same reasons than cgsgIterate.

Parameters:

cgsgPointIsInRegion

(
  • point
  • targetRegion
  • threshold
)
Boolean

Parameters:

  • point Object

    a CGSGPosition

  • targetRegion Object

    a CGSGRegion

  • threshold Object

    an integer

Returns:

Boolean:

true if the point is inside the region or around this one in a distance of threshold

cgsgRegionIsInRegion

(
  • region
  • targetRegion
  • threshold
)
Boolean

Parameters:

Returns:

Boolean:

true if the point is inside the region or around this one in a distance of threshold