Skip to main content

createPolygon

Creates a new polygon (defaults to a triangle).

Signature

createPolygon(): PolygonNode

Remarks

By default, the new node has three edges (i.e. a triangle), a default fill, width and height both at 100, and is parented under figma.currentPage.

Create a red octagon
const polygon = figma.createPolygon()

// Move to (50, 50)
polygon.x = 50
polygon.y = 50

// Set size to 200 x 200
polygon.resize(200, 200)

// Make the polygon 8-sided
polygon.pointCount = 8

// Set solid red fill
polygon.fills = [{ type: 'SOLID', color: { r: 1, g: 0, b: 0 } }]

On this page