psychopy.org | Reference | Downloads | Github

Error message: "color components should all belong to [-1,1]"

URL of experiment:
https://run.pavlovia.org/lebaec7/timebased/html/?__pilotToken=aab3238922bcc25a6f606eb525ffdc56&__oauthToken=b5925defcc2d3ecdba312553bd30c9caa94624e5e5b6b379e7ba355074b91363

Description of the problem:
When I try to run a PsychoPy experiment as a pilot, it doesn’t start but shows the following error message:


Another member of my research group doesn’t get the same error message.
Does anyone know of this error and could help me to solve the problem?
Thank you!

In PsychoPy the default colour space is [-1, -1, -1] to [1, 1, 1] rather than [0, 0, 0] to [255, 255, 255]

1 Like

Hi, thank you very much for your help! I saw that you answered in an earlier blog post from 2020 about the same question. Do I have to manually change all the color names in Builder? So instead of “black” I’d use “$[-1,-1,-1]”?
Thank you!

You should be able to use a colour name in a Builder component. Please could you show an example of a component that isn’t working?

1 Like

The thing is, I don’t know which components exactly don’t work (it doesn’t say, and it can’t start the experiment at all). But I guess one of the first color component would be the polygon here:

Later on, we also used $msgColor to direct to code embedded first in the same routine, where color names were used as well:

Do you think, the latter could be the issue? Otherwise, we didn’t use that many colors, actually. And the weird thing about it is that a colleague doesn’t have these issues using the same files…

Thank you very much, I’m grateful for your help!

The code is the problem. My crib sheet and code snippets page show a way of defining colours as variables,

1 Like

Okay, at least I know what’s the problem now!
I’m still struggling to solve it, though. Is it enough if I define color variables in the first routine of my experiment and then use those variables in the code? If I run the experiment offline, it works, but online the error persists…
I’m not sure if I misunderstood something about defining the colours in a code_Both component.


loadDecks appears top be a Python online code component, and will therefore not do anything online. If you change it to a Both component then you can have rd = [1,0,0] on the Python side and rd = new util.Color([1,0,0]); on the JavaScript side.

I think this should also work with named colours, e.g.

red = 'red'
red = new util.Color("red");
1 Like

Thank you very much, it worked now!