Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

How to set grayscale color (value:0-255) shapes in Opensesame?

I have checked the visual section of the Psychopy API and found out that there is no corresponding parameter to assign in the psychopy.visual.Circle() function. Can anyone help me with this? Thanks a lot!


Comments

  • Hi @Ornella ,

    Is your question about what kind of units psychopy (by default and in the context of OpenSesame) uses for color specifications? These are on a -1 (black) to 1 (white) scale, so if you have values on a 0 (black) to 255 (white) scale you'd convert them as follows:

    psychopy_color = (my_color - 128) / 128
    

    Does that clear things up?

    — Sebastiaan

  • edited March 2024

    Hi @sebastiaan,

    Thanks for your help! I just want to draw grey circles of different lightness(I don't know if I'm phrasing this correctly?). So can I set the Circle.color to a value between -1 and 1, like this?

    stim_size = 100
    my_color = random.randint(0, 255)
    gray_scale = (my_color - 128) / 128
    cnvs += Circle(x, y, stim_size/2, color=gray_scale, fill=True)
    

    But I noticed that no matter what the value of Circle.color is between -1 and 1, I get black circles (see figure below). Have I misunderstood? I look forward to hearing your answer.


  • Hi @Ornella ,

    Ok, I see. The Circle() class in OpenSesame is not the same as the psycho.visual.Circle() class, hence the confusion. (The first is to draw on an OpenSesame Canvas object, the second to draw on a PsychoPy window object. They are conceptually similar in that they both draw a circle, but they do so in a different context.)

    You can see how to specify colors in OpenSesame here:

    One way is actually to simply specify an integer between 0 (black) and 255 (white), which seems to be exactly what you need:

    cnvs += Circle(0, 0, 50, color=0, fill=True)  # black
    cnvs += Circle(0, 0, 50, color=255, fill=True)  # white
    

    Hope this helps!

    — Sebastiaan

  • Hi @sebastiaan,

    That works! Thank you very much!🤗🤗

Sign In or Register to comment.