Skip to content

Instantly share code, notes, and snippets.

@iandol
Last active August 19, 2019 05:43
Show Gist options
  • Save iandol/165be2c62cd996ec1afa609d6c5838fe to your computer and use it in GitHub Desktop.
Save iandol/165be2c62cd996ec1afa609d6c5838fe to your computer and use it in GitHub Desktop.
Bug in DrawFormatted2 but only on MATLAB 2019b
function degtest()
bgColour = 0.5;
screen = max(Screen('Screens'));
screenSize = [];
ptb = mySetup(screen,bgColour,screenSize);
text = sprintf('The <b>distance<b> is %.2f°\nThe <b>size<b> is %.2f°',56.13,12.75);
% text=strrep(text,'°','d') %uncomment at it then works...
Priority(MaxPriority(ptb.win)); %bump our priority to maximum allowed
Screen('Flip', ptb.win);
DrawFormattedText2(text,'win',ptb.win)
Screen('Flip', ptb.win);
WaitSecs('YieldSecs',2);
end
%----------------------
function ptb = mySetup(screen, bgColour, ws)
ptb.cleanup = onCleanup(@myCleanup);
PsychDefaultSetup(2); KbName('UnifyKeyNames');
Screen('Preference', 'SkipSyncTests', 1);
if isempty(screen); screen = max(Screen('Screens')); end
ptb.ScreenID = screen;
PsychImaging('PrepareConfiguration');
PsychImaging('AddTask', 'General', 'FloatingPoint32BitIfPossible');
PsychImaging('AddTask', 'General', 'NormalizedHighresColorRange');
[ptb.win, ptb.winRect] = PsychImaging('OpenWindow', ptb.ScreenID, bgColour, ws, [], [], [], 1);
[ptb.w, ptb.h] = RectSize(ptb.winRect);
screenWidth = 405; % mm
viewDistance = 573; % mm
ptb.ppd = ptb.w/2/atand(screenWidth/2/viewDistance);
ptb.ifi = Screen('GetFlipInterval', ptb.win);
ptb.fps = 1 / ptb.ifi;
Screen('BlendFunction', ptb.win, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
end
%----------------------
function myCleanup()
disp('Clearing up...')
sca
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment