-
-
Notifications
You must be signed in to change notification settings - Fork 162
/
Copy pathmain.js
24 lines (20 loc) · 771 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
let {Path, Color, scenegraph} = require("scenegraph");
let commands = require("commands");
let addTriangle = selection => {
// create triangle
let triangle = new Path();
triangle.pathData = "M 508.5 543 L 388.0343933105469 751.6587524414062 L 628.2350463867188 751.6587524414062 L 508.5 543 Z";
triangle.stroke = new Color("#000");
triangle.strokeWidth = 4;
selection.insertionParent.addChild(triangle);
// place triangle on artboard
let parentCenter = triangle.parent.localCenterPoint;
let triangleLocation = triangle.localBounds;
let triangleCord = {x: triangleLocation.x * 1.3, y: triangleLocation.y * 1.3};
triangle.placeInParentCoordinates(triangleCord, parentCenter);
}
module.exports = {
commands: {
addTriangle
}
};