-
Notifications
You must be signed in to change notification settings - Fork 1
/
code.ts
27 lines (25 loc) · 827 Bytes
/
code.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
figma.showUI(__html__, {
width: 520,
height: 346,
});
figma.ui.onmessage = msg => {
// One way of distinguishing between different types of messages sent from
// your HTML page is to use an object with a "type" property like this.
if (msg.type === 'create-rectangles') {
const nodes: SceneNode[] = [];
for (let i = 0; i < msg.count; i++) {
const rect = figma.createRectangle();
rect.x = i * 150;
rect.fills = [{type: 'SOLID', color: {r: 1, g: 0.5, b: 0}}];
figma.currentPage.appendChild(rect);
nodes.push(rect);
}
figma.currentPage.selection = nodes;
figma.viewport.scrollAndZoomIntoView(nodes);
}
if (msg.type === 'layout-done') {
let node = figma.createNodeFromSvg(msg.svg);
figma.viewport.scrollAndZoomIntoView([node]);
}
figma.closePlugin();
};