-
Notifications
You must be signed in to change notification settings - Fork 7
/
marching.sketchplugin
39 lines (30 loc) · 1.26 KB
/
marching.sketchplugin
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
28
29
30
31
32
33
34
35
36
37
38
39
var layer = selection[0];
var layerWidth = [[layer frame] width];
var layerHeight = [[layer frame] height];
var frame = [layer frame];
var parent = [layer parentGroup];
var startingX = [frame x];
var startingY = [frame y];
var rowCount = [doc askForUserInput:"How many rows do you want?" initialValue:"5"]
var colCount = [doc askForUserInput:"How many columns do you want?" initialValue:"3"]
//var widthPercentage = [doc askForUserInput:"How close do you want the columns?" initialValue:"50"]
var heightPercentage = [doc askForUserInput:"How close do you want the rows?" initialValue:"50"]
var widthOffset = layerWidth / 100 * 50; //widthPercentage;
var heightOffset = layerHeight / 100 * (100 - heightPercentage);
for (var row=0; row<rowCount; row++) {
for (var col=0; col<colCount; col++) {
if ((row % 2 == 1) && (col == colCount -1)) {
continue;
}
var clone = [layer duplicate];
var frame2 = [clone frame];
if (row % 2 == 1) {
//[frame2 setX: (col * (layerWidth) + widthOffset) + startingX];
[frame2 setX: (col * (layerWidth) + widthOffset) + startingX];
} else {
[frame2 setX: (col * (layerWidth)) + startingX];
}
[frame2 setY: -row * (layerHeight - heightOffset) + startingY];
}
}
[layer setIsVisible:false];