object:setStrokeColor()

Type Function
Object ShapeObject
Library display.*
Return value none
Revision Release 2024.3703
Keywords setStrokeColor, border color, stroke color
See also object:setFillColor()
display.newRect()
display.newRoundRect()
display.newCircle()
display.newPolygon()

Overview

Sets the stroke (border) color of vector objects.

Syntax

object:setStrokeColor( gray )
object:setStrokeColor( gray, alpha )
object:setStrokeColor( red, green, blue )
object:setStrokeColor( red, green, blue, alpha )
gray, red, green, blue, alpha (required)

Numbers. Numbers between 0 and 1 that represent the corresponding value for that channel. alpha represents the opacity of the stroke.

Gotchas

If you are passing a table of color values to this function, the table must be unpacked so that the color values are dictated properly:

local rect = display.newRect( 150, 150, 100, 100 )

local colorTable = { 1, 0, 0, 0.5 }
rect:setStrokeColor( unpack(colorTable) )

Example

local rect = display.newRect( 150, 150, 100, 100 )
rect:setFillColor( 1, 1, 0.8 ) 
rect:setStrokeColor( 1, 0, 0 )
rect.strokeWidth = 8