Complete the code to create a rectangle shape in Figma.
const rectangle = figma.create[1]();The Rectangle shape is created using figma.createRectangle() in Figma's plugin API.
Complete the code to set the fill color of a shape to red.
rectangle.fills = [{ type: 'SOLID', color: { r: [1], g: 0, b: 0 } }];In Figma, color values range from 0 to 1. To set red fully, use r: 1.
Fix the error in the code to add the rectangle to the current page.
figma.currentPage.[1](rectangle);The correct method to add a node to the page in Figma is appendChild().
Fill both blanks to create a circle shape and set its radius.
const circle = figma.create[1](); circle.[2] = 50;
Circles are created with createEllipse(). The radius is set by cornerRadius for perfect circles.
Fill all three blanks to create a text element, set its content, and add it to the page.
const text = figma.create[1](); text.[2] = 'Hello World'; figma.currentPage.[3](text);
Text elements are created with createText(). The text content is set with characters. To add it to the page, use appendChild().