-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
br_new_foreground_color.jsx
61 lines (55 loc) · 2.08 KB
/
br_new_foreground_color.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#target photoshop
if (app.documents.length !== 0) {
var doc = app.activeDocument;
// Generate random bright and saturated color
// var colorMax = [255, Math.floor(Math.random() * 106) + 150, Math.floor(Math.random() * 106) + 150];
// colorMax = shuffleArray(colorMax); // Randomize the order
// var red = colorMax[0];
// var green = colorMax[1];
// var blue = colorMax[2];
// Begin recording a new action
var idMk = charIDToTypeID("Mk ");
var desc47 = new ActionDescriptor();
var idnull = charIDToTypeID("null");
var ref27 = new ActionReference();
var idcontentLayer = stringIDToTypeID("contentLayer");
ref27.putClass(idcontentLayer);
desc47.putReference(idnull, ref27);
var idUsng = charIDToTypeID("Usng");
var desc48 = new ActionDescriptor();
var idType = charIDToTypeID("Type");
var desc49 = new ActionDescriptor();
var idClr = charIDToTypeID("Clr ");
var desc50 = new ActionDescriptor();
var idRd = charIDToTypeID("Rd ");
// desc50.putDouble(idRd, red);
// var idGrn = charIDToTypeID("Grn ");
// desc50.putDouble(idGrn, green);
// var idBl = charIDToTypeID("Bl ");
// desc50.putDouble(idBl, blue);
// var idRGBC = charIDToTypeID("RGBC");
// desc49.putObject(idClr, idRGBC, desc50);
var idsolidColorLayer = stringIDToTypeID("solidColorLayer");
desc48.putObject(idType, idsolidColorLayer, desc49);
var idcontentLayer = stringIDToTypeID("contentLayer");
desc47.putObject(idUsng, idcontentLayer, desc48);
executeAction(idMk, desc47, DialogModes.NO);
// Add layer mask
var idMk = charIDToTypeID( "Mk " );
var desc21 = new ActionDescriptor();
var idNw = charIDToTypeID( "Nw " );
var idMsk = charIDToTypeID( "Msk " );
desc21.putClass( idNw, idMsk );
} else {
alert("There are no open documents");
}
// Shuffle function
function shuffleArray(array) {
for (var i = array.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = array[i];
array[i] = array[j];
array[j] = temp;
}
return array;
}