| Reference | Downloads | Github

Pavlovia - "the color components should all belong to [-1, 1]" error

PsychoPy 3.2.4
macOS Mojave
Chrome 78.0.3904.108
Project ID: 14601

Description of the problem:
Hi! I’ve uploaded an experiment to Pavlovia, but when I try to run it I get the error “the color components should all belong to [-1, 1]”. I’m fairly new to all of this so I can’t quite figure out how to deal with this error. I tried changing all hex color codes to RGB codes, but I still get the same error. Any ideas?


1 Like

hello! I’ve met the same problem, may I ask how to do this exactly?

(I’ve only put images and a video in my program, there is no polygon.

I solved the issue of converting regular RGB values (1-255) to the -1 to 1 scale that PsychoPy/PsychoJS uses with this formula.

Step 1. Define a function

function changeRGBFormat(RGBVal) {
let result = (RGBVal-127.5)/(255-127.5); // This is the formula to convert RGB Values to the -1 to 1 scale
return Math.round(10*result)/10;

rgbArray = [87,12,200]

Step 2. Use .map() to iterate that function over RGB val array

converted =;

Step 3. Use the newly created array to instantiate a new Color object.

new util.Color(converted);


Hi! Sorry if my answer is too trivial but still… I have the same error message. My experiment was designed in Builder solely. Could you please explain if it’s possible to overcome the problem in the builder by probably changing the values or something? Basically I need a white screen at a certain point and the colour was defined in rgb $[10, 10, 10]. How could I put that into this [-1, 1] range?

On what scale is [10,10,10] white? That's nearly black in RGB255. White in the [-1,1] range is [1,1,1]

1 Like

Hi, thanks for the reply! This is strange but I think it was set to 10, 10, 10 and the experiment worked in the builder and the layer was white. Once I tried to run it online, I had this error. But since you’re saying it can’t be so, given it should be nearly black, I’m no longer sure it was on 10, 10, 10. I’ve changed it now to 1,1,1 and it works. I can’t explain what I have been doing the whole day, so your answer helped me! Thank you! :slight_smile:

1 Like