-
Notifications
You must be signed in to change notification settings - Fork 0
/
PaintEffect-Color-Changer.jsx
58 lines (43 loc) · 1.56 KB
/
PaintEffect-Color-Changer.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
function hexToRGB(theHex){
theHex = parseInt(theHex,16);
var r = theHex >> 16;
var g = (theHex & 0x00ff00) >> 8;
var b = theHex & 0xff;
return [r/255,g/255,b/255];
};
function buildUI(thisObj){
var main_wnd;
if(thisObj instanceof Panel){
main_wnd = thisObj ;
}else{
main_wnd = new Window("palette", "PaintEffect-Color-Changer", undefined, {resizeable : false});
}
main_wnd.preferredSize = [120,80]
var input_text = main_wnd.add("edittext", undefined, "",{multiline : false});
input_text.alignment = ["fill","fill"];
var ok_btn = main_wnd.add("button", undefined, "OK");
ok_btn.alignment = ["fill","bottom"];
main_wnd.layout.layout();
ok_btn.onClick = function(){
var activeItem = app.project.activeItem;
var activeItemLayer = activeItem.selectedLayers[0]
if(activeItem){
if(activeItemLayer.selectedProperties[0].name == "ペイント" || activeItemLayer.selectedProperties[0].name == "Paint"){
for (var i = 1; i <= Number(activeItemLayer.selectedProperties.length-1); i++) activeItemLayer.selectedProperties[i].strokeOption.color.setValue(hexToRGB(input_text.text));
}else{
alert("Paint effect not selected.");
}
}else{
alert("The active item is not selected.");
}
}
main_wnd.onResize = function(){
main_wnd.layout.resize();
}
return main_wnd;
}
var toolspanel = buildUI (this);
if(!(toolspanel instanceof Panel)){
toolspanel.center();
toolspanel.show();
}