-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathradialRepeat.jsx
57 lines (52 loc) · 2.09 KB
/
radialRepeat.jsx
1
#target photoshop// radialRepeat.jsx// https://github.com/amatecha/// Copyright (c) 2014 Andrew Matecha <[email protected]>// Some rights reserved. See LICENSE.// DESCRIPTION// This simple "radial repeat" script will repeat your artwork X number of times in a circular pattern.// Start with an empty layer into which you have drawn some content. It must be a new transparent layer, not the Background layer.// SETTINGS// To change the total number of nodes in the resulting graphic, change the "numberOfNodes" value below.// If you would like to be prompted for this number every time you run the script, change "promptForNumberOfNodes" to true.// You can get some interesting results by changing the number of nodes each time you run the script.var numberOfNodes = 16;var promptForNumberOfNodes = false;// SCRIPTvar document = app.activeDocument;var origLayer = document.activeLayer;if (origLayer.isBackgroundLayer) { alert("Before using this script, the graphics you wish to repeat must be in a new layer (not the Background layer). A new empty layer has now been created for you to use."); document.artLayers.add();} else if (origLayer.kind == "LayerKind.TEXT") { alert("You cannot use a text layer with this script. Please use a raster (normal) layer instead.");} else { if (promptForNumberOfNodes) { numberOfNodes = prompt("How many total nodes/repeats do you want to have?", 16); } document.activeHistoryBrushSource = document.activeHistoryState; resetLayer(origLayer); createNodes(); document.mergeVisibleLayers(); document.selection.deselect(); document.artLayers.add();}function resetLayer(layer) { layer.pixelsLocked = false; layer.allLocked = false; layer.positionLocked = false; layer.transparentPixelsLocked = false;}function createNodes() { var angle = 360 / parseInt(numberOfNodes); for (var i = 1; i < numberOfNodes; i++) { var newLayer = origLayer.duplicate(); document.selection.selectAll(); try { newLayer.rotate(angle * i); } catch(e) { alert("You must have some graphics in the active layer before you can use this script."); return; } };}