Skip to main content
Version: Phaser v4.0.0

DrawLine

A RenderNode which computes the geometry of a line segment and expands it into a quad suitable for WebGL rendering.

A line segment has two endpoints (a and b) and can have a different width at each end, allowing tapered lines. This node calculates the four corner vertices of the quad that represents the line, by offsetting perpendicular to the line direction by the respective half-widths at each end. The resulting vertices are optionally transformed by a matrix and appended to a flat vertex list.

This node is used internally by the WebGL renderer when drawing stroked paths, such as those produced by Graphics Game Objects.

Constructor

new DrawLine(manager)

Parameters

nametypeoptionaldescription
managerPhaser.Renderer.WebGL.RenderNodes.RenderNodeManagerNoThe manager that owns this RenderNode.

Scope: static

Extends

Phaser.Renderer.WebGL.RenderNodes.RenderNode

Source: src/renderer/webgl/renderNodes/DrawLine.js#L10
Since: 4.0.0

Inherited Methods

From Phaser.Renderer.WebGL.RenderNodes.RenderNode:


Public Methods

run

<instance> run(drawingContext, currentMatrix, ax, ay, bx, by, aLineWidth, bLineWidth, vertices)

Description:

Computes the four vertices of the quad that represents a line segment and appends them to the provided vertices list. The line can vary in width between its start point (a) and end point (b), producing a tapered shape. Eight values are appended (four x/y pairs) in the order TL, BL, BR, TR, relative to the line's direction.

Parameters:

nametypeoptionaldescription
drawingContextPhaser.Renderer.WebGL.DrawingContextNoThe context currently in use.
currentMatrixPhaser.GameObjects.Components.TransformMatrixNoA transform matrix to apply to the vertices. If not defined, the vertices are not transformed.
axnumberNoThe x coordinate of the start of the line.
aynumberNoThe y coordinate of the start of the line.
bxnumberNoThe x coordinate of the end of the line.
bynumberNoThe y coordinate of the end of the line.
aLineWidthnumberNoThe width of the line at the start.
bLineWidthnumberNoThe width of the line at the end.
verticesArray.<number>NoThe list to which the vertices are assigned.

Overrides: Phaser.Renderer.WebGL.RenderNodes.RenderNode#run

Source: src/renderer/webgl/renderNodes/DrawLine.js#L40
Since: 4.0.0


Inherited Members

From Phaser.Renderer.WebGL.RenderNodes.RenderNode: