Created
January 21, 2011 19:23
-
-
Save milesegan/790236 to your computer and use it in GitHub Desktop.
knob rotation image sequence generator script for photoshop
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 knob generation script | |
// This script assumes your source document contains a layer group | |
// called "indicator" that can be successively rotated around its | |
// center to generate a series of rotation state images. | |
// - Miles Egan January 2011 | |
// change this to the number of discrete rotations you want | |
var numRotations = 65; | |
var rotAngle = 270; | |
var step = rotAngle / (numRotations - 1); | |
// save units | |
var originalUnit = preferences.rulerUnits; | |
preferences.rulerUnits = Units.PIXELS; | |
// setup dest doc | |
var src = app.activeDocument; | |
var savedState = src.activeHistoryState; | |
var dX = src.width; | |
var dY = src.height; | |
var dst = app.documents.add(dX, dY * numRotations); | |
dst.artLayers[0].isBackgroundLayer = false; | |
dst.artLayers[0].clear(); | |
// build & copy rotations | |
for (var i = 0; i < numRotations; i++) { | |
// reset state to avoid cumulative rotation noise | |
app.activeDocument = src; | |
src.activeHistoryState = savedState; | |
var set = src.layerSets["indicator"]; | |
set.rotate(step * i, AnchorPosition.MIDDLECENTER); | |
src.mergeVisibleLayers(); | |
src.artLayers[0].copy(); | |
app.activeDocument = dst; | |
var dstRect = [ | |
[0, i * dY], [dX, i * dY], [0, (i + 1) * dY], [dX, (i + 1) * dY] | |
]; | |
dst.selection.select(dstRect); | |
dst.paste(); | |
} | |
// cleanup | |
app.activeDocument = src; | |
src.activeHistoryState = savedState; | |
app.activeDocument = dst; | |
dst.mergeVisibleLayers(); | |
dst.artLayers[0].name = "knob"; | |
preferences.rulerUnits = originalUnit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi,
does this still work in CC 2018? I just tried it but can't seem to get it to work...
This would be very handy to have!
![screen shot 2018-01-17 at 09 25 00](https://user-images.githubusercontent.com/5762670/35035149-597fbaec-fb68-11e7-9d6f-b9ddd818ddcf.png)
correction yes it is still working! wonderful:)
so I need to have the indicator group at base level and selected it seems!
![screen shot 2018-01-17 at 11 37 15](https://user-images.githubusercontent.com/5762670/35040908-cbcba6f8-fb7a-11e7-8ca7-74790672b436.png)