API Docs for: v2.1.0
Show:

CGSGSceneGraph Class

Extends Object
Module: Scene

Represent the scene graph it self.

Constructor

CGSGSceneGraph

(
  • canvas
  • context
)

Parameters:

  • canvas HTMLElement

    a handler to the canvas HTML element

  • context CanvasRenderingContext2D

    context to render on

Methods

_invalidateThemeRecursive

(
  • n
)
private

Parameters:

addNode

(
  • node
  • parent
)

Add a node on the scene. If the root does not already exist, this node will be used as root

Parameters:

  • node CGSGNode

    the node to add

  • parent CGSGNode

    the parent node of the new one. If it's null, the node will be the root.

deselectAll

(
  • excludedArray
)

Mark all nodes as not selected

Parameters:

  • excludedArray Array

    CGSGNodes to not deselect

deselectNode

(
  • nodeToDeselect
)

Mark the nodes as not selected

Parameters:

initializeGhost

(
  • w
  • h
)
private

Initialize the ghost rendering, used by the PickNode function

Parameters:

  • w Number

    width The width for the canvas. Must be the same as the rendering canvas

  • h Number

    height The height for the canvas. Must be the same as the rendering canvas

invalidateTheme

()

Used to enforce theme invalidation for each node during next rendering loop

pickNode

(
  • mousePosition
  • condition
)
CGSGNode

Recursively traverse the nodes and return the one who is under the mouse coordinates

Parameters:

Returns:

Example:

this.scenegraph.picknode(mousePosition, 'position.x > 100');
this.scenegraph.picknode(mousePosition, 'position.x > 100 && this.position.y > 100');

pickNodes

(
  • region
  • condition
)
Array

Recursively traverse the nodes and return the ones who are under the mouse coordinates

Parameters:

Returns:

Example:

this.scenegraph.picknodes(region, 'position.x > 100');
this.scenegraph.picknodes(region, 'position.x > 100 && this.position.y > 100');

removeNode

(
  • node
)
Boolean

Remove the child nodes passed in parameter, from the root nodes

Parameters:

Returns:

Boolean:

true if the nodes was found and removed

render

() public

Render the SceneGraph

selectNode

(
  • nodeToSelect
)

Mark the nodes as selected so the select marker (also called selectedHandlers) will be shown and the SceneGraph will manage the moving and resizing of the selected objects.

Parameters:

  • nodeToSelect Object

    The CGSGNode to be selected

setCanvasDimension

(
  • newDimension
)

Change the dimension of the canvas. Does not really change the dimension of the rendering canvas container, but is used for different computations

Parameters:

String.prototype.addFirstDot

() String

Provided by the Util module.

Defined in src\utils\util.string.js:53

Add a dot ('.') as first character if it's not already a dot

Returns:

String:

A String with the first '.'

String.prototype.capitalize

(
  • lower
)
String

Provided by the Util module.

Defined in src\utils\util.string.js:65

Capitalize first letter of the String

Parameters:

  • lower Boolean

    if true, all other letters will be lowercased

Returns:

String.prototype.collapse

() String

Provided by the Util module.

Defined in src\utils\util.string.js:38

Return same String by replacing space, dot and minus by the following letter uppercased

Returns:

String.prototype.without

(
  • t
)
String

Provided by the Util module.

Defined in src\utils\util.string.js:27

Return same String without string in parameter

Parameters:

Returns:

Properties

_nextNodeID

Number private

context

CanvasRenderingContext2D

ghostCanvas

HTMLElement

Initialize a ghost canvas used to determine which nodes are selected by the user

root

CGSGNode

Root node of the graph