Using DrawformattedText to display text
27 ビュー (過去 30 日間)
古いコメントを表示
The question asks for the following:
- The DISPLAY TEXT section should display text in Courier font, with a text-size approximately 1/20th the height of the screen. Don’t just hard-code a number for the text-size; have Matlab compute it (IMPORTANT: The text-size must be a whole-number). The displayed text should include the following, all put on the screen at once:
- The words “RED TOP-LEFT” (with the word “RED” positioned directly above the word “TOP- LEFT”) in red text, centered in the top-left quadrant of the screen.
- The words “GREEN TOP-RIGHT” (with the word “GREEN” positioned directly above the word “TOP-RIGHT”) in green text, centered in the top-right quadrant of the screen.
- The words “BLUE BOTTOM-LEFT” (with the word “BLUE” positioned directly above the word “BOTTOM-LEFT”) in blue text, centered in the bottom-left quadrant of the screen.
- The words “YELLOW BOTTOM-RIGHT” (with the word “YELLOW” positioned directly above the word “BOTTOM-RIGHT”) in yellow text, centered in the bottom-right quadrant of the screen.
- The words “RANDOM GRAY CENTER” (with the words “RANDOM GRAY” positioned directly above the word “CENTER”) in a randomly generated grayscale tone, centered on the screen. This text—and only this text—should be bold.
I have the following code but the red and the green overlay and the blue does not appear on the screen. Im not sure how to fix it.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SETUP
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all
close all
sca
rng shuffle
Screen ('Preference','VisualDebugLevel',1);
Screen('Preference','SkipSyncTests',1);
mainScreenNum = max(Screen('Screens'));
PsychDebugWindowConfiguration
w = PsychImaging('OpenWindow',mainScreenNum,[100 149 237]);
ListenChar(2)
HideCursor
Screen('BlendFunction',w,'GL_SRC_ALPHA','GL_ONE_MINUS_SRC_ALPHA');
[wWidth,wHeight]=Screen('WindowSize',w);
xmid=round(wWidth/2);
ymid=round(wHeight/2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DISPLAY TEXT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Screen ('TextSize',w,wHeight/20);
Screen('TextFont',w,'Courier');
topLeftQuadRect = [0 0 xmid ymid];
topRightQuadRect = [xmid 0 0 ymid];
bottomLeftQuadRect = [0 ymid xmid 0];
bottomRightQuadRect = [xmid ymid 0 0];
DrawFormattedText(w,'RED\nTOP-LEFT','center','center',[255 0 0],[],[],[],[],[],topLeftQuadRect);
DrawFormattedText(w,'GREEN\nTOP-RIGHT','center','center',[0 255 0],[],[],[],[],[],topRightQuadRect);
DrawFormattedText(w,'BLUE\nBOTTOM-LEFT','center','center',[0 0 255],[],[],[],[],[],bottomLeftQuadRect);
Screen('Flip',w);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EXIT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
KbWait;
sca
0 件のコメント
回答 (1 件)
Pratheek Punchathody
2021 年 1 月 22 日
編集済み: Pratheek Punchathody
2021 年 1 月 22 日
As per my understanding PsychToolbox is a third party toolbox. Feel free to contact the owner and the community of the toolbox for further information regarding implementation.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!