Skip to content

Instantly share code, notes, and snippets.

@hiloki
Created November 23, 2024 03:08
Show Gist options
  • Save hiloki/23052e8be7fb7624d1066b19719cabbc to your computer and use it in GitHub Desktop.
Save hiloki/23052e8be7fb7624d1066b19719cabbc to your computer and use it in GitHub Desktop.
Color Swatch
const colors = [
figma.util.rgb("#bbf7d0"),
figma.util.rgb("#86efac"),
figma.util.rgb("#4ade80"),
figma.util.rgb("#22c55e"),
figma.util.rgb("#16a34a"),
];
const rectangleWidth = 100; // 矩形の幅
const rectangleHeight = 100; // 矩形の高さ
const spacing = 20; // 矩形間のスペース
colors.forEach((color, index) => {
const rect = figma.createRectangle();
rect.resize(rectangleWidth, rectangleHeight);
rect.x = index * (rectangleWidth + spacing); // 水平方向に並べる
rect.y = 0; // 垂直方向は同じ位置
rect.fills = [{ type: "SOLID", color: color }];
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment