Complete the code to add a second fill to the selected element in Figma.
figma.currentPage.selection[0].fills = [...figma.currentPage.selection[0].fills, [1]];
To add a new fill, you use figma.createPaint() which creates a paint object for fills.
Complete the code to set the opacity of the second fill to 50%.
const fills = figma.currentPage.selection[0].fills.slice(); fills[1].opacity = [1]; figma.currentPage.selection[0].fills = fills;
Opacity values range from 0 to 1, so 50% opacity is 0.5.
Fix the error in the code to correctly assign multiple fills to the element.
figma.currentPage.selection[0].fills = [1];
The fills property expects an array of paint objects, so it must be wrapped in square brackets.
Fill in the blank to create a linear gradient fill and assign it as the second fill.
const gradientFill = { type: [1], gradientStops: [], gradientTransform: [[1, 0, 0], [0, 1, 0]] }; const fills = figma.currentPage.selection[0].fills.slice(); fills[1] = gradientFill; figma.currentPage.selection[0].fills = fills;To create a linear gradient fill, the type must be 'GRADIENT_LINEAR'.
Fill all three blanks to create a new solid fill with red color and add it as the first fill.
const newFill = { type: [1], color: { r: [2], g: [3], b: 0 } }; const fills = figma.currentPage.selection[0].fills.slice(); fills.unshift(newFill); figma.currentPage.selection[0].fills = fills;The fill type for solid color is 'SOLID'. Red color has r=1, g=0, b=0.