Created
September 17, 2018 12:08
-
-
Save benjohnde/faf2f3719bba92ac1990c1fb96be69c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function exportArtboard(artboard, file_path) { | |
var frame = artboard.frame() | |
var artboardWidth = frame.width() | |
var artboardHeight = frame.height() | |
var overlayName = artboard.name().replace(/\.| /g, "") | |
var shapes = [] | |
var layers = artboard.layers() | |
for (var j = 0; j < layers.count(); j++) { | |
var layer = layers[j] | |
if (layer.class() == "MSLayerGroup" && layer.name() == "cassette_outline") { | |
var groupFrame = layer.frame() | |
var groupX = groupFrame.x() | |
var groupY = groupFrame.y() | |
var parts = layer.layers() | |
for (var k = 0; k < parts.count(); k++) { | |
var part = parts[k] | |
var shape = processShape(part, groupX, groupY, artboardWidth, artboardHeight) | |
shapes.push(shape) | |
} | |
} | |
} | |
const code = genericOverlayClassSwift(overlayName, shapes) | |
// Save the file | |
const string = NSString.stringWithFormat("%@", code); | |
const filename = `${file_path}${overlayName}.swift` | |
return string.writeToFile_atomically(filename, true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment