Hello,I’d like to create a grating with red and blue stripe .But when I compile the code from builder view , I don’t know where the complementary color in grating is defined and how to chage it. I’ve tried so many times but failed. Thank you so much if you could help me .
I’m going to assume you’re using a GratingStim object rather than an EnvelopeGrating. I’m not sure how you could do this with an EnvelopeGrating, but with a GratingStim, it comes down to a tricky argument.
In your Python code, wherever the object is defined (just search for the name of the component), you should see something like this
grating = visual.GratingStim(
win=win, name='grating',
tex='sin', mask=None,
ori=0, pos=(0, 0), size=(0.5, 0.5), sf=None, phase=0.0,
color=[1,-1,-1], colorSpace='rgb', opacity=1,blendmode='avg',
texRes=128, interpolate=True, depth=-1.0)
(This is the Python file, for running locally; there will be a separate one in the javascript file for running online when you sync to Pavlovia.)
The keys here are the arguments “color” and “contrast”. Color defines one color of the grating, in this case using RGB space. [1,-1,-1] is just red (red is set to maximum, blue to minimum, green to minimum). Contrast is an optional argument (not visible by default) that defines the alternate color in the grating. It defaults to 1. If you add to the arguments:
contrast=[-1,1,-1]
In theory, that should make the alternating color pure blue.
If that doesn’t work (and I haven’t tested it, so it may well not), the other option is to make a second grating in alternating phase with the first that is the other color.
I’m so grateful for your response! I just tried to change the “contrast”,but it seems to define the visibility that the stimulus is relative to background,which is the same function as “opacity”. I’ll try the second option. Anyway, thank you so much for your help!