Copy link to clipboard
Copied
Hello everyone!
How do I assign color correction values to my slider? I know it must be very complex but I need to add a "adjust colors" panel in a dialog using ScitiptUI. I've looked at some examples here but have not seen anything like it. Any and all help will be very important.
Here I did a small cyan and red adjustment model:
#target Photoshop
var w = new Window ("dialog","Color Balance",[0,0,270,100],);
var value = w.add ("edittext {text: 0, characters: 3, justify: 'center', active: true}",[114,10,40,20] );
var cyan=w.add("statictext",[14,38,40,85] ,"Cyan",{multiline:true});
var red=w.add("statictext",[225,38,300,85],"Red",{multiline:true});
var slider = w.add ("slider {minvalue: -50, maxvalue: 150, value: 50}",[43,30,220,50]);
slider.onChanging= function () {
value.text = slider.value - 50
}
//////////////////
value.onChanging = function () {
slider.value = Number (value.text) + 50
}
w.center();
w.show();
It's not entirely clear to me why you're mimicking the native Color Balance dialog, but who am I to judge 😉
Please try this code:
...var w = new Window ("dialog","Color Balance",[0,0,270,100],);
var value = w.add ("edittext {text: 0, characters: 5, justify: 'center', active: true}",[114,10,40,20] );
var cyan=w.add("statictext",[14,38,40,85] ,"Cyan",{multiline:true});
var red=w.add("statictext",[225,38,300,85],"Red",{multiline:true});
var slider = w.add ("slider {minvalue: -100, maxvalue: 100, va
Copy link to clipboard
Copied
Looks like your sample script is working. What seems to be the issue?
Copy link to clipboard
Copied
Hi Chuck Uebele actually I wanted to refer to the direct values in the image.
Example:
The slider would work this way: -100% to 0% = Cyan ..... 0% to + 100% = Red
When I move the slider to the right, I would enter a percentage of red in the image and if I move the slider to the left it would enter cyan percentage.
I tried to use the ScriptingListener to write + 25% and -25% of red but I just managed to assign the positive value, I do not know how to assign the slider the correction with negative value.
Copy link to clipboard
Copied
Are you employing an Adjustment Layer?
Copy link to clipboard
Copied
Hi c.pfaffenbichler, I do not usually use adjustment layers, I have to fix it directly on the selected layer.
That was all I could do even though I did not get a way to add the negative value to the image when I move the slider to the left.
#target Photoshop
var w = new Window ("dialog","Color Balance",[0,0,270,100],);
var value = w.add ("edittext {text: 0, characters: 3, justify: 'center', active: true}",[114,10,40,20] );
var cyan=w.add("statictext",[14,38,40,85] ,"Cyan",{multiline:true});
var red=w.add("statictext",[225,38,300,85],"Red",{multiline:true});
var slider = w.add ("slider {minvalue: -50, maxvalue: 150, value: 50}",[43,30,220,50]);
slider.onChange= function () {
value.text = slider.value - 50
var CR = slider.value;
cyan_red(CR);
app.refresh();
}
///////////////
value.onChange= function () {
slider.value = Number (value.text) + 50
}
function cyan_red(CR){
///////////////
///add red
ClrB();
function ClrB() {
var desc409 = new ActionDescriptor();
var list4 = new ActionList();
var list5 = new ActionList();
var list6 = new ActionList();
list4.putInteger( 0 );
list4.putInteger( 0 );
list4.putInteger( 0 );
desc409.putList( charIDToTypeID( "ShdL" ), list4 );
list5.putInteger( 25 );
list5.putInteger( 0 );
list5.putInteger( 0 );
desc409.putList( charIDToTypeID( "MdtL" ), list5 );
list6.putInteger( 0 );
list6.putInteger( 0 );
list6.putInteger( 0 );
desc409.putList( charIDToTypeID( "HghL" ), list6 );
desc409.putBoolean( charIDToTypeID( "PrsL" ), true );
executeAction( charIDToTypeID( "ClrB" ), desc409, DialogModes.NO );
}
///////////////
}
w.center();
w.show();
Copy link to clipboard
Copied
If I understand you correctly and you immediately and destructively apply the adjustment I recommend you reconsider your approach.
Copy link to clipboard
Copied
It would be somewhat similar to Photoshop's color balance (Ctrl + B), but custom to fit a panel that will also be part of the dialog box I'm doing. It would be a great opportunity to learn how slides work for certain adjustments.
I am happy for your attention and the willingness to help me in this complex work.
Copy link to clipboard
Copied
It's not entirely clear to me why you're mimicking the native Color Balance dialog, but who am I to judge 😉
Please try this code:
var w = new Window ("dialog","Color Balance",[0,0,270,100],);
var value = w.add ("edittext {text: 0, characters: 5, justify: 'center', active: true}",[114,10,40,20] );
var cyan=w.add("statictext",[14,38,40,85] ,"Cyan",{multiline:true});
var red=w.add("statictext",[225,38,300,85],"Red",{multiline:true});
var slider = w.add ("slider {minvalue: -100, maxvalue: 100, value: 0}",[43,30,220,50]);
var doc = app.activeDocument;
var lay = doc.activeLayer;
var currentStatus = doc.activeHistoryState;
function applyRoutine() {
doc.activeHistoryState = currentStatus;
lay.adjustColorBalance(
[0, 0, 0],
[slider.value, 0, 0],
[0, 0, 0],
true
);
app.refresh();
}
slider.onChange= function () {
value.text = Math.round(slider.value);
var CR = slider.value;
applyRoutine();
}
value.onChange= function () {
slider.value = Number(value.text);
applyRoutine();
}
w.center();
w.show();
A couple of points: first, if you don't turn back to a "clear" history state, each time you move the slider you're going to sum the color balance effect – which I understand it's not what you're after. Second, you're better using the DOM approach and not ActionManager code for the adjustColorBalance. I've bound the slider to the Midtone Cyan/Red, it's pretty clear where to intervene in the arrays to change the behaviour.
Hope this helps!
Cheers,
Davide
Copy link to clipboard
Copied
Great King Davide! How did you do the magic of adding exactly the colors I quoted above? I confess I did not find out. Starting from this principle, my task now is to add the other sidere with the other color adjustments type: Magenta / Green, yellow / blue .... brightness / Contrast. Impressive, what secret, where can I find these references?
Thank you so much for the great work Davide_Barranca
Copy link to clipboard
Copied
The adjustColorBalance function is documented in the Photoshop Javascript Reference that you can find here: Adobe Photoshop Scripting , the bit you're interested into is:
See the way I've used it in the code.
Cheers,
Davide
Copy link to clipboard
Copied
Thank you Davide! I took a tremendous beating here to understand, but I was able to configure the other color adjustments.
Line 15
[slider.value, 0, 0], = Red/Cyan
[0, slider.value, 0], = Magenta/Green
[0, 0, slider.value], = Yellow/Blue
Thank you so much again Davide_Barranca
Find more inspiration, events, and resources on the new Adobe Community
Explore Now