CGSGSceneGraph Class
Represent the scene graph it self.
Constructor
CGSGSceneGraph
-
canvas
-
context
Parameters:
-
canvas
HTMLElementa handler to the canvas HTML element
-
context
CanvasRenderingContext2Dcontext to render on
Item Index
Methods
Properties
Methods
addNode
-
node
-
parent
Add a node on the scene. If the root does not already exist, this node will be used as root
deselectAll
-
excludedArray
Mark all nodes as not selected
Parameters:
-
excludedArray
ArrayCGSGNodes to not deselect
initializeGhost
-
w
-
h
Initialize the ghost rendering, used by the PickNode function
invalidateTheme
()
Used to enforce theme invalidation for each node during next rendering loop
pickNode
-
mousePosition
-
condition
Recursively traverse the nodes and return the one who is under the mouse coordinates
Parameters:
-
mousePosition
CGSGPosition -
condition
String
Returns:
Example:
this.scenegraph.picknode(mousePosition, 'position.x > 100');
this.scenegraph.picknode(mousePosition, 'position.x > 100 && this.position.y > 100');
pickNodes
-
region
-
condition
Recursively traverse the nodes and return the ones who are under the mouse coordinates
Parameters:
-
region
CGSGRegion -
condition
String
Returns:
Example:
this.scenegraph.picknodes(region, 'position.x > 100');
this.scenegraph.picknodes(region, 'position.x > 100 && this.position.y > 100');
removeNode
-
node
Remove the child nodes passed in parameter, from the root nodes
Parameters:
-
node
CGSGNodethe nodes to remove
Returns:
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
ObjectThe 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:
-
newDimension
CGSGDimension
String.prototype.addFirstDot
()
String
Add a dot ('.') as first character if it's not already a dot
Returns:
A String with the first '.'
String.prototype.capitalize
-
lower
Capitalize first letter of the String
Parameters:
-
lower
Booleanif true, all other letters will be lowercased
Returns:
String.prototype.collapse
()
String
Return same String by replacing space, dot and minus by the following letter uppercased
Returns:
Properties
context
CanvasRenderingContext2D
ghostCanvas
HTMLElement
Initialize a ghost canvas used to determine which nodes are selected by the user