Cannot change the color of my words in my script

Hi everyone,

I’m a newbie just starting off coding my experiments in PTB. I’ve had no problem whatsoever getting the hang of everything I need, except that I’m basically unable to define the color of the words presented on the screen. I’d like the color to be red amongst other parameters. Here’s the bit of code where I define both the screen format and the word color:

%%Default settings for setting up psychtoolbox
w = Screen(‘OpenWindow’,screenNumber,,[0 0 1280 800 ]);
Screen(‘TextSize’,w, 30);

for i = 1:36

%Inducer task
DrawFormattedText(w, 'myword'],'center','center', [1 0 0] ,0);



As I understand the color is determined with the vector [1 0 0] in DrawFormattedText. Everything from the font to the size of the letters is just as I wanted except the word remains desperately black…

Any idea where the bug is?? Let me know if you need any clarification from me.


color range for your display may well be 0-255. try [255 0 0]

Diederick is close: Your PsychDefaultSetup(2); command requests a unified color range from 0.0 - 1.0, but for this to have an effect, you need to open your window with PsychImaging('OpenWindow',...) instead of Screen('OpenWindow',...), or that request will not have any effect. Screen() would continue to expect 0-255 old-style colors and a value of [1 0 0] would be treated as 1/255 of max red intensity, iow. very dark red, instead of 100% == maximum red. The Screen('ColorRange', ...) command allows low-level control of color ranges, but using PsychImaging() is a better choice.

In general it is a good idea to always use the high level PsychImaging('OpenWindow',...) instead of the lower level Screen() subfunction. It exposes a lot of useful functionality conveniently beyond what Screen itself does. I’d go as far as everybody should skim ‘help PsychImaging’ for what functionality it provides before ever writing a real experiment script. It exposes much of the advanced visual stimulation functionality that sets Psychtoolbox far apart from all other similar experiment software and can make life easier.


Thanks Mario, i learned something too

Thank you both! I’ll try with the PsychImaging function.