original → modified +12 -8
@@ -1,6 +1,3 @@
1
- // Sketch Plugin: AEIconizer (ctrl shift i)
2
- // Source: github.com/tadija/AEIconizer
3
-
4
var iTunesSizes = [NSArray arrayWithObjects: 512, nil]
5
var iOSSizes = [NSArray arrayWithObjects: 83.5, 76, 60, 40, 29, 20, nil]
6
var watchOSSizes = [NSArray arrayWithObjects: 98, 86, 27.5, 24, nil]
@@ -15,7 +12,9 @@
15
removeExistingIcons(context)
16
iconize(originalIcon)
17
[[doc currentView] centerLayersInCanvas]
18
} else {
19
[doc showMessage:"Oops, icon artboard must have same width and height"]
20
}
21
}
@@ -29,14 +28,20 @@
29
if([selection count] == 0) {
30
if ([[[doc currentPage] artboards] count] == 1) {
31
iconArtboard = [[[doc currentPage] artboards] firstObject]
32
} else {
33
- [doc showMessage:"Oops, you have to select something"]
34
}
35
} else {
36
var currentSelection = selection[0]
37
if (currentSelection.className() == "MSArtboardGroup") {
38
iconArtboard = currentSelection
39
} else {
40
iconArtboard = [currentSelection parentArtboard]
41
if (!iconArtboard) {
42
[doc showMessage:"Oops, selection has to be inside artboard"]
@@ -103,12 +108,12 @@
103
var icon = scaleIcon(originalIcon, newSize, iconName)
104
configureExportOptionsForLayer(icon)
105
106
- if (newSize == 512) {
107
[[icon absoluteRect] setRulerX:fromX]
108
[[icon absoluteRect] setRulerY:fromY]
109
110
newY = [[icon absoluteRect] y]
111
- }
112
else {
113
if (maxX == 0) {
114
maxX = fromX + 512 + spacing
@@ -124,7 +129,6 @@
124
newY = newMaxY + spacing
125
}
126
}
127
-
128
}
129
130
return newY
@@ -147,4 +151,4 @@
147
[[layer exportOptions] addExportFormat]
148
[[layer exportOptions] addExportFormat]
149
[[layer exportOptions] addExportFormat]
150
- }
1
var iTunesSizes = [NSArray arrayWithObjects: 512, nil]
2
var iOSSizes = [NSArray arrayWithObjects: 83.5, 76, 60, 40, 29, 20, nil]
3
var watchOSSizes = [NSArray arrayWithObjects: 98, 86, 27.5, 24, nil]
12
removeExistingIcons(context)
13
iconize(originalIcon)
14
[[doc currentView] centerLayersInCanvas]
15
+
16
} else {
17
+
18
[doc showMessage:"Oops, icon artboard must have same width and height"]
19
}
20
}
28
if([selection count] == 0) {
29
if ([[[doc currentPage] artboards] count] == 1) {
30
iconArtboard = [[[doc currentPage] artboards] firstObject]
31
+
32
} else {
33
+
34
+ [doc showMessage:"Oops, you have to select an Artboard"]
35
}
36
+
37
} else {
38
+
39
var currentSelection = selection[0]
40
if (currentSelection.className() == "MSArtboardGroup") {
41
iconArtboard = currentSelection
42
+
43
} else {
44
+
45
iconArtboard = [currentSelection parentArtboard]
46
if (!iconArtboard) {
47
[doc showMessage:"Oops, selection has to be inside artboard"]
108
var icon = scaleIcon(originalIcon, newSize, iconName)
109
configureExportOptionsForLayer(icon)
110
111
+ if (newSize == 512) {
112
[[icon absoluteRect] setRulerX:fromX]
113
[[icon absoluteRect] setRulerY:fromY]
114
115
newY = [[icon absoluteRect] y]
116
+ }
117
else {
118
if (maxX == 0) {
119
maxX = fromX + 512 + spacing
129
newY = newMaxY + spacing
130
}
131
}
132
}
133
134
return newY
151
[[layer exportOptions] addExportFormat]
152
[[layer exportOptions] addExportFormat]
153
[[layer exportOptions] addExportFormat]
154
+ }