display.newLine()

Type Function
Library display.*
Return value LineObject
Revision Release 2022.3683
Keywords lines, vector
See also object:setStrokeColor()
object.strokeWidth
object:append()

Overview

Draw a line from one point to another. Optionally, you may append points to the end of the line to create outline shapes or paths.

Gotchas

Currently, display.newLine() objects do not support touch/tap events.

Syntax

display.newLine( [parent,] x1, y1, x2, y2 [, x3, y3, ... ] )
parent (optional)

GroupObject. An optional display group in which to insert the line.

x1 / y1 (required)

Numbers. Coordinates of the beginning of the line.

x2 / y2 (required)

Numbers. Coordinates of the end of the line.

x3, y3, ... (optional)

Numbers. Additional coordinates.

Example

local star = display.newLine( 200, 90, 227, 165 )
star:append( 305,165, 243,216, 265,290, 200,245, 135,290, 157,215, 95,165, 173,165, 200,90 )
star:setStrokeColor( 1, 0, 0, 1 )
star.strokeWidth = 8