Skip to main content

DrawNode

Description:

  A record for scene node that draws simple shapes such as dots, lines, and polygons.

Class Object: DrawNode Class.

Inherits from: Node.

depthWrite

Type: Field.

Description:

  Whether to write to the depth buffer when drawing (default is false).

Signature:

depthWrite: boolean

blendFunc

Type: Field.

Description:

  The blend function used to draw the shape.

Signature:

blendFunc: BlendFunc

drawDot

Type: Function.

Description:

  Draws a dot at a specified position with a specified radius and color.

Signature:

drawDot: function(
self: DrawNode,
pos: Vec2,
radius: number,
color?: Color --[[0xffffffff]]
)

Parameters:

ParameterTypeDescription
posVec2The position of the dot.
radiusnumberThe radius of the dot.
colorColor[optional] The color of the dot (default is white).

drawSegment

Type: Function.

Description:

  Draws a line segment between two points with a specified radius and color.

Signature:

drawSegment: function(
self: DrawNode,
from: Vec2,
to: Vec2,
radius: number,
color?: Color --[[0xffffffff]]
)

Parameters:

ParameterTypeDescription
fromVec2The starting point of the line.
toVec2The ending point of the line.
radiusnumberThe radius of the line.
colorColor[optional] The color of the line (default is white).

drawPolygon

Type: Function.

Description:

  Draws a polygon defined by a list of vertices with a specified fill color and border.

Signature:

drawPolygon: function(
self: DrawNode,
verts: {Vec2},
fillColor?: Color --[[0xffffffff]],
borderWidth?: number --[[0]],
borderColor?: Color --[[0xffffffff]]
)

Parameters:

ParameterTypeDescription
verts{Vec2}The vertices of the polygon.
fillColorColor[optional] The fill color of the polygon (default is white).
borderWidthnumber[optional] The width of the border (default is 0).
borderColorColor[optional] The color of the border (default is white).

drawVertices

Type: Function.

Description:

  Draws a set of vertices as triangles, each vertex with its own color.

Signature:

drawVertices: function(self: DrawNode, verts: {{Vec2, Color}})

Parameters:

ParameterTypeDescription
verts{{Vec2, Color}}The list of vertices and their colors.

clear

Type: Function.

Description:

  Clears all previously drawn shapes from the node.

Signature:

clear: function(self: DrawNode)