// Sample script to create a simple rectangle in Figma using the Plugin API
const figma = require('figma-api');

const createRectangle = () => {
  const rect = figma.createRectangle();
  rect.x = 100;
  rect.y = 100;
  rect.width = 200;
  rect.height = 100;
  rect.fills = [{type: 'SOLID', color: {r: 0.96, g: 0.67, b: 0.69}}];
  figma.currentPage.appendChild(rect);
};

createRectangle();

Links and Resources

Advanced Scripting Example


// Advanced script to analyze text layers in a Figma document for font size consistency
const figma = require('figma-api');

const analyzeTextLayers = async () => {
  const textLayers = figma.currentPage.findAll(node => node.type === 'TEXT');
  let report = {};

  textLayers.forEach(layer => {
    const fontSize = layer.fontSize;
    if (!report[fontSize]) {
      report[fontSize] = 1;
    } else {
      report[fontSize]++;
    }
  });

  console.log('Font Size Consistency Report:', report);
};

analyzeTextLayers();