logoBMates

Node

Node is the most basic graphics class in Renderer.

All objects that contain basic functions and have no children belong to Node.

Check Container and Group for objects that act like Node and have children.

Properties

name: string

The name of the Node. The default value is Node.

x: number

The x-coordinate of the Node.

y: number

The y-coordinate of the Node.

width: number

The width of the Node.

height: number

The height of the Node.

parent: Container | null

Parent container with Node as a child.

Default value is null.

Automatically assigned through add(). For Stage, the top node, it is a null value.

visible: boolean

The visibility state of the Node.

draggable: boolean

Indicates whether the Node is draggable.

zIndex: number

The z-index of the Node.

They are reordered compared to other Nodes at the same level.

Constructor

constructor (attrs: Partial<NodeAttributes> = {})

attrs: Partial<NodeAttributes>

Sets the initial properties of the Node.

Methods

update (dT)

Updates the state of the Node.

NameTypeDescription
dTnumberDelta time

Called before draw().

draw (ctx)

Draws the Node.

NameTypeDescription
ctxCanvasRenderingContext2DRendering context for the drawing surface

Called after update().

isIntersection (x, y)

Checks if the given coordinates intersect with the Node.

NameTypeDescription
xnumberThe x-coordinate to check for intersection.
ynumberThe y-coordinate to check for intersection.
  • Return: boolean

hitTest (point, e)

Checks if the given point collides with the Node.

NameTypeDescription
pointVector2The point to check for collision.
eMouseEventThe mouse event associated with the hit test.
  • Return: Node | null
    • The Node if a collision occurs, otherwise null.

getStage ()

  • Return: Stage | null

toObject ()

Extract key attribute data.

  • Return: object

destroy ()

Safely removes the Node.

PREVTimeIndicatorNEXTContainer
logoBMates