Last active
August 29, 2015 14:26
-
-
Save matt-curtis/bfd4c86b1a375a3fb31a to your computer and use it in GitHub Desktop.
Script for use with the default Sketch iOS App Icon Template. Takes the selected layer and duplicates it to the other artboard sizes.
This file contains 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
var original = context.selection.firstObject(); | |
var originalArtboard = original.parentArtboard(); | |
var artboards = context.document.artboards(); | |
var enumerator = artboards.objectEnumerator(); | |
var artboard; | |
while((artboard = enumerator.nextObject())){ | |
if(artboard.isEqual_(originalArtboard)) continue; | |
var originalSize = original.frame().width(); | |
var targetSize = artboard.frame().width(); | |
var clone = original.duplicate(); | |
// resize | |
var ratio = targetSize / originalSize; | |
[clone multiplyBy:ratio]; | |
// add to artboard | |
clone.parentGroup().removeLayer(clone); | |
artboard.layers().addObject_(clone); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment