Created
January 18, 2013 07:17
-
-
Save yosun/4562902 to your computer and use it in GitHub Desktop.
Alphabet block generator Photoshop Script (jsx) - Loop through and create a centered character for each character in @str, uses background defined by @FileRef, and saves everything in @fileLoc/str[i].png
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
// Loop through and create a centered character for each character in @str, uses background defined by @fileRef, and saves everything in @fileLoc/str[i].png | |
// of all the characters on the keyboard, apparently : is the only character you cannot start a filename with ... :.png is invalid (manually excepted to colon.png)! | |
// @yosun 1/27/2013 11:11 | |
var originalUnit = preferences.rulerUnits; | |
preferences.rulerUnits = Units.PIXELS; | |
var docRef; var artLayerRef; var textItemRef; | |
var type="diffuse"; | |
var str = "DEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),.;':\"<>?/\\|~`-_ ¢£€¥ƒ¤÷°±ÀÈÌÒÙÁÉÍÓÚÝÂÊÎÔÛÃÑÕÄËÏÖÜŸÇ¡¿ŒÆÐØÅߊŽ§¶"; | |
var fileRef; | |
if(type=="diffuse")fileRef = new File("/Users/yosun_mbpr15/AlphaArm/Graphics/block_background-diffuse.png"); | |
else fileRef = new File("/Users/yosun_mbpr15/AlphaArm/Graphics/block_background-normal.png"); | |
var fileLoc = "/Users/yosun_mbpr15/AlphaArm/Graphics/blocks/"; | |
for(var i=0;i<str.length;i++){ | |
docRef = app.open(fileRef);///.documents.add(1024,1024); | |
artLayerRef = docRef.artLayers.add(); | |
artLayerRef.kind = LayerKind.TEXT; | |
textItemRef = artLayerRef.textItem; | |
textItemRef.justification = Justification.CENTER; | |
textItemRef.size = 800; | |
textItemRef.position = [512,512]; | |
textItemRef.baselineShift=-260; | |
var sc = new SolidColor(); | |
if(type=="diffuse"){ | |
sc.rgb.red=Math.random()*255; | |
sc.rgb.green=Math.random()*255; | |
sc.rgb.blue=Math.random()*255; | |
}else{ | |
sc.rgb.red=255;sc.rgb.blue=255;sc.rgb.green=255; | |
} | |
textItemRef.color = sc; | |
var myFont = app.fonts.getByName("AmericanTypewriter"); | |
textItemRef.font=myFont.postScriptName; | |
textItemRef.contents = str[i]; | |
var pngSaveOptions = new PNGSaveOptions(); | |
docRef.saveAs(new File(fileLoc+str[i]+".png"),pngSaveOptions,true,Extension.LOWERCASE); | |
docRef.close(SaveOptions.DONOTSAVECHANGES); | |
} | |
docRef = null; | |
artLayerRef = null; | |
textItemRef = null; | |
app.preferences.rulerUnits = originalUnit; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment