Doesn't pavlovia have the ability to randomize colors?

OS : win10
PsychoPy version : 2021.2.3

I made the random color circle in my builder.
It works well in PsychoPy, but not in the pavlovia.
I don’t know what is the problem and what to do for making it works well.

Hi @Warala, could you show the code that does the randomization?

Hi,
I just put the variable name like the picture, and randomize with loop system.
It is based on the excel file below.
image

Could it be the problem that you only have one value where multiple are needed? Or do you need values between 0 and 255? Maybe PsychoJS only understands RGB values?

What exactly happens when you run it on pavlovia?

Every time the polygon appears black…

And I try to make them to 255rgb, but it didn’t work.
Still blacks.

That’s weird. Could you share your experiment file and the conditions file?

Maybe this will help you: Colors are not appearing in shapes for online experiment - #10 by wakecarter

Thank you, it’s helpful information.
But still I can’t make it :disappointed_relieved:
I put circle.setFillColor(new util.Color(startColor)); in the JS window.
However in pavlovia, now the program shows me the loading page forever,

If that is the case, it probably means that something is wrong with your code. You can press ctrl + shift + K (in Firefox) to look at the console and see where the initialization of the experiment fails.

1 Like

I think you’re spot on with needing multiple values - PsychoJS definitely understands different color spaces (rgb = -1 to 1, rgb1 = 0 to 1, rgb255 = 0 to 255) and as the color space in Builder is set to rgb it should interpret values between -1 and 1 correctly. However, I can’t confirm whether the code we have in PsychoPy which treats -1 in a colors.Color object as being the same as (-1, -1, -1) exists in PsychoJS, so that would be the most likely avenue. This is easily tested, so I’ll do a big of digging and find out!

Okay, it looks like it’s a combination of factors: It does need to be multiple values for JS, and you also need to specify the color space as there appears to be a bug in the Builder script (which I’ve just put in a bug fix for) which means color space wasn’t used in the JS boilerplate.

For now, you can set the value of the color in Builder to be:

$new util.Color([startColor, startColor, startColor], util.Color.COLOR_SPACE.RGB)

and this should work in the current version

1 Like

Hi,
Thanks for the new way!

I tried too late, and got a new problem now.
If I put the code you gave me on the value blank of color, I can’t run it on the PsychoPy itself.
Or put it on the code component, pavlovia says syntax error…

How can I through this again?:disappointed_relieved:

image

I solved the running error, but I still have this error…

There’s a bug in some of the recent PsychoPy versions which means that when you use the colour picker you are just given the numbers. Try changing 0,0,0 to $[0,0,0] in Experiment Settings.

Hello, thank you for your kind explanation.
I did it, and Pavlovia succeeded in getting the program running.

But the final goal is to update the color values, but it still doesn’t work…:joy:
Can I have a solution for that?

My code of color is below.

Have you looked at my method of defining colours as variables in a Both component at the start of the experiment? Try my crib sheet or code snippets

1 Like

OMG
I succeeded!

The key was making Experiment Settings $[0,0,0],
and making JS code to

new util.fillColor([startColor, startColor, startColor])

Thank you very much for your attention and great resources!!!

1 Like