Set Background Color

Hi,
I think this could be a bug.
I am using PS 23.0.0.
The following script should set the background color but it sets the foreground color.
I maybe wrong so, can someone check and give feedback please?

var exeModal = require('photoshop').core.executeAsModal;

await exeModal(() => {
const result1 =  batchPlay(
[
   {
      "_obj": "set",
      "_target": [
         {
            "_ref": "color",
            "_property": backgroundColor
         }
      ],
      "to": {
         "_obj": "HSBColorClass",
         "hue": {
            "_unit": "angleUnit",
            "_value": 222
         },
         "saturation": 48,
         "brightness": 59
      },
      "source": "photoshopPicker",
      "_isCommand": true,
      "_options": {
         "dialogOptions": "dontDisplay"
      }
   }
],{
   "synchronousExecution": true,
   "modalBehavior": "execute"
});})

Could you try backgroundColor with quotes?

Sorry, my mistake (as usual) but it does not work.
To get back to the main question, maybe the error is in my script but, it works very well to set foreground color.
I call the function with an argument: groundColor (“backgroundColor”); which sets the foreground color.
To set forground I use groundColor (“foregroundColor”); which sets the foreground color.

const groundColor =  async (ground) => {
var newColor = ColorPicker();
var Hue = newColor.color.hue._value;
var Sat = newColor.color.saturation;
var Bright = newColor.color.brightness;

await exeModal(() => {
const result1 =  batchPlay(
[
   {
      "_obj": "set",
      "_target": [
         {
            "_ref": "color",
            "_property": ground
         }
      ],
      "to": {
         "_obj": "HSBColorClass",
         "hue": {
            "_unit": "angleUnit",
            "_value": Hue
         },
         "saturation": Sat,
         "brightness": Bright
      },
      "source": "photoshopPicker",
      "_isCommand": true,
      "_options": {
         "dialogOptions": "dontDisplay"
      }
   }
],{
   "synchronousExecution": true,
   "modalBehavior": "execute"
});})

}
1 Like