How can I revert psychoJS to taking an RGB for screen colour?

I had previously tried to change the screen colour in the Properties → Screen → Color field for my experiment in the builder. This failed every time since PsychoPy never accepted whatever value I input, even if I took it from the colourpicker. I gave up and set it back to 0,0,0, which seemed to work fine for Psychopy.

However, somewhere along the way, the transpiler to javasctip started interpreting that argument as a string, see the below code

psychoJS.openWindow({
  fullscr: true,
  color: new util.Color('[0,0,0]'),
  units: 'norm',
  waitBlanking: true
});

And now I can’t go back. I don’t want to specify a colour by a name, because this means the code doesn’t work for PsychoPy, so I would have to maintain two difference code bases for the same experiment. I tried manually changing that line of code in the coder (also not ideal) but it just overwrote my change next time I updated the project in the builder.

Please tell me how I can revert PsychoJS into accepting an RGB tuple as a colour argument, rather than expecting a string.

Printing as a string is a bug which I believe is fixed in the next version, I’ll check though. You can force it to be code by adding a dollar sign, like so:
$[0, 0, 0]

UPDATE

Can confirm, in the version currently being built the following values for window color compile to JS as follows:

Builder JS
0,0,0 new util.Color([0,0,0])
[0,0,0] new util.Color([0,0,0])
$[0,0,0] new util.Color([0,0,0])
'grey' new util.Color('grey')

All of which will set the window color to be exact mid-grey, if your color space is rgb.

1 Like