Setting rgb255 colors on Pavlovia

Description of the problem: I’m not sure if this is a bug or if I’m doing something wrong, but the rgb255 color-space setting isn’t working for me on Pavlovia. I have a shape component called imageOutline and I set the fill color to $outlineColor and selected ‘rgb255’ in the dropdown color-space menu. Then I set the r, g, and b in a code component and have the fill color set to every repeat (have also tried every frame). This works just fine in builder, but I get the error the color components should all belong to [-1, 1]. I also tried to set the color to $[.5,.5,.5] in the shape component and wrote the code imageOutline.setFillColor(outlineColor, {"colorSpace": "rgb255"}); (intentionally js code) to force it to become rbg255, but then it just stays [.5,.5,.5] and doesn’t change with the code. So then I tried $outlineColor in the shape component again, but now with the code in the code component, and it goes back to the error. Am I doing something wrong or does Pavlovia just not like the rgb255 setting? TIA!

P.S. I really need the colors to be in rgb255 color-space because I’m replicating my in-person experiment and these specific colors were chosen very meticulously. If I try to translate them to a [-1,1] scale, I’m afraid it’ll round up decimals or something and they won’t be the exact same.

You could check the accuracy of (colVal/127.5)-1 by taking a screenshot of the experiment, pasting it into a graphics package and then using the colour picker to check the colour of the patch.

Have a look at my crib sheet for how to define colours in a Both component (if you are setting colours in code components).

Hey, so I did the calculations to get my 255 colors to [-1, 1] and they are nowhere near the same. I only just now realized this when a participant told me they saw more than one green target in a stream… Do you know if PsychoJS rounds the numbers maybe? It’s strange because javascript alone doesn’t like the [-1, 1] colors and only uses rgb255, yet the util.Color function that PsychoJS uses the opposite. Like in the .js file, it uses:

  color1 = new visual.Rect ({
    win: psychoJS.window, name: 'color1', 
    width: [0.1, 0.1][0], height: [0.1, 0.1][1],
    ori: 0, pos: [(- 0.66), (- 0.33)],
    lineWidth: 1, lineColor: new util.Color([(- 1.0), (- 1.0), (- 1.0)]),
    fillColor: new util.Color([0.6745098039215687, 0.5372549019607843, 0.6745098039215687]),
    opacity: 1, depth: -8, interpolate: true,
  });

If instead of fillColor: new util.Color([color value]) it used fillColor: ([color value]), I’m pretty sure it would accept rgb255 values only. I’m afraid of touching the actual .js code because then I can’t go back to using builder, so I was wondering if you knew of a way to make the code see new util.Color as nothing in a similar way that you do with your codeJS conversions you have in your crib sheet? Or do you have an idea of what else could be going wrong with my rgb255 to [-1, 1] conversions? What is this [-1, 1] scale even called? I’m trying to google how to convert rgb and I literally can’t find any [-1, 1] color scales anywhere. The closest I can find is [0, 1].

Have you actually compared screenshots of the converted colours? I wouldn’t trust a report from a participant knowing how often people disagree about whether certain colours in real life are blue or green.

Oh yeah definitely! They were all shades of pink and green.

I realized that when you right click on the color field, it has spots to enter rgb values, so I did that to get PsychoJS’s version of the colors. It’s strange because they were the exact same values you get when you use the formula, but with a few less decimal places. I’m not sure why that happens, but for anyone else searching for this in the future, that’s what you do! :+1: