Copy link to clipboard
Copied
I download this script that randomly fill all selected paths with the selected swatches:
mySelection = app.activeDocument.selection;
myDoc = app.activeDocument;
if (mySelection instanceof Array)
{
selSwatches = myDoc.swatches.getSelected();
if(selSwatches.length != 0)
for (i=0; i<mySelection.length; i++)
{
if(mySelection.typename == "PathItem" || mySelection.typename == "CompoundPathItem")
{
selItem = mySelection;
selItem.filled = true;
swatchIndex = Math.round( Math.random() * (selSwatches.length - 1 ));
if(selItem.typename == "PathItem")
selItem.fillColor = selSwatches[swatchIndex].color;
else
selItem.pathItems[0].fillColor = selSwatches[swatchIndex].color;
}
}
}
I would like to adapt it to stroke randomly with all selected brushes
Copy link to clipboard
Copied
This would be amazingly useful!
Copy link to clipboard
Copied
There is no function to "get" selected brushes, but you can still choose which brushes to randomly apply. In the snippet below, you choose a list of brushes based on a first and last. (Brushes are numbered starting with 1 from the panel's upper left .)
firstBrushNo = 2; // <- enter number
lastBrushNo = 4; // <- enter number
theBrushes = app.activeDocument.brushes;
for (i = 0; i < app.selection.length; i++){
brushIndex = Math.floor(Math.random()*((lastBrushNo - 1) - (firstBrushNo - 1) + 1)) + (firstBrushNo - 1);
theBrushes[brushIndex].applyTo(app.selection[i]);
}
For example, you can choose to randomly apply the brushes between the second and fourth (inclusive).