-
-
Save Arahnoid/0a2837dd5a7d28864e6d to your computer and use it in GitHub Desktop.
Photoshop script for preparing a sprite for rotating animation
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
/** | |
* Photoshop script for preparing a sprite for rotating animation. | |
* Input : a starting sprite and number of frames | |
* Output: the specified number of layers ready to be used in the PS animation tool | |
*/ | |
var docRef = app.activeDocument; | |
var activeLayer = docRef.activeLayer; | |
var degToRotate = null; | |
var newLayer = null; | |
var secondLayer = null; | |
// Number of frame in total, including the original one | |
var numFrames = prompt('How many frames, including the original frame(layer)?', 36); | |
var degEachFrame = 360 / numFrames; // In degree | |
for(var i=0; i < numFrames - 1 ; i++) { | |
degToRotate = degEachFrame * (i + 1); | |
newLayer = activeLayer.duplicate(); | |
newLayer.rotate(degToRotate); | |
newLayer.visible = false; | |
if(!secondLayer) secondLayer = newLayer; | |
} | |
// Move the original layer to the top sprite | |
activeLayer.move(secondLayer, ElementPlacement.PLACEBEFORE); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment