Complete the code to export a frame as a PNG file in Figma.
figma.currentPage.findOne(node => node.name === 'Frame1').exportAsync({ format: '[1]' })
To export an image as a PNG, the format must be set to 'PNG'.
Complete the code to select all components in the current page.
const components = figma.currentPage.findAll(node => node.type === '[1]')
The node type for components is 'COMPONENT'.
Fix the error in the code to create a rectangle and set its fill color to red.
const rect = figma.createRectangle()
rect.fills = [{ type: 'SOLID', color: [1] }]
figma.currentPage.appendChild(rect)Figma color values are decimals between 0 and 1, so red is { r: 1, g: 0, b: 0 }.
Fill both blanks to create a text node with content and set its font size.
const text = figma.createText()
await figma.loadFontAsync({ family: '[1]', style: 'Regular' })
text.characters = '[2]'
text.fontSize = 24
figma.currentPage.appendChild(text)Roboto is a common font family and 'Hello World' is the text content.
Fill all three blanks to create a component from a frame and rename it.
const frame = figma.createFrame() frame.resize(200, 100) const component = figma.[1]() component.name = '[2]' figma.currentPage.appendChild(component) console.log(component.[3])
Use createComponent() to make a component, set its name to 'Button', and log its name property.
