object:setStrokeVertexColor()

Type Function
Object ShapeObject
Library display.*
Return value none
Revision Release 2024.3703
Keywords setStrokeVertexColor, vertex color, stroke, vector
See also [object:setFillVertexColor()][api.type.ShapeObject.setFillStrokeColor]
display.newRect()
display.newRoundRect()
display.newCircle()
display.newText()
display.newPolygon()

Overview

Sets the color of a particular stroke vertex in vector objects.

Until a given stroke vertex color has been assigned, it is interpreted as white. The color of the object at each vertex is a combination of its stroke color and stroke vertex color: the two red values multiplied together produce the final red, and so on for the remaining channels. When the object is drawn, the resulting colors are interpolated between neighboring vertices.

The first time this is called on an object, some extra memory will be allocated to it to store the colors.

Syntax

object:setStrokeVertexColor( index, gray )
object:setStrokeVertexColor( index, gray, alpha )
object:setStrokeVertexColor( index, red, green, blue )
object:setStrokeVertexColor( index, red, green, blue, alpha )
index (required)

Numbers Integer from 1 to object.strokeVertexCount indicating which stroke vertex to color.

gray, red, green, blue, alpha (optional)

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

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:

``````lualocal rect = display.newRect( 150, 150, 100, 100 )

local colorTable = { 1, 0, 0, 0.5 } rect:setStrokeVertexColor( 2, unpack(colorTable) ) ``````

Examples

lualocal rect = display.newRect( 150, 150, 100, 100 ) rect:setFillColor( 1, 1, 0.8 ) rect:setStrokeVertexColor( 1, 1, 0, 0 ) -- index = 1; r, g, b = (1, 0, 0) rect.strokeWidth = 8