Skip to content

Instantly share code, notes, and snippets.

@smithdanielle
Last active August 29, 2015 14:15

Revisions

  1. smithdanielle revised this gist Feb 12, 2015. 1 changed file with 15 additions and 15 deletions.
    30 changes: 15 additions & 15 deletions expeditionNum.m
    Original file line number Diff line number Diff line change
    @@ -1,39 +1,39 @@
    runNum = input('run number: ');

    % Load rocket image
    rocket.load = imread('rocket2.png');
    rocket.texture = Screen('MakeTexture', windowPtr, rocket.load);
    endRocket.load = imread('rocket2.png');
    endRocket.texture = Screen('MakeTexture', windowPtr, endRocket.load);
    % Get the size of the image
    [s1, s2, s3] = size(rocket.load);
    [s1, s2, s3] = size(endRocket.load);
    % Get the aspect ratio of the image. We need this to maintain the aspect
    % ratio of the image when we draw it different sizes. Otherwise, if we
    % don't match the aspect ratio the image will appear warped / stretched
    aspectRatio = s2 / s1;
    heightScalers= 0.5;
    imageHeights = screenParams.Res(2) .* heightScalers;
    imageWidths = imageHeights .* aspectRatio;
    theRect = [0 0 imageWidths imageHeights];
    dstRects = CenterRectOnPointd(theRect, xcen,...
    ycen+(0.25*imageHeights));
    endRocket.aspectRatio = s2 / s1;
    endRocket.heightScalers= 0.5;
    endRocket.imageHeights = screenParams.Res(2) .* endRocket.heightScalers;
    endRocket.imageWidths = endRocket.imageHeights .* endRocket.aspectRatio;
    endRocket.theRect = [0 0 endRocket.imageWidths endRocket.imageHeights];
    endRocket.dstRects = CenterRectOnPointd(endRocket.theRect, xcen,...
    ycen+(0.25*endRocket.imageHeights));

    endText = ['EXPEDITION ', num2str(runNum), ' OF 4 \n COMPLETE'];

    % Prepare the end screen
    % Select left-eye image buffer for drawing:
    Screen('SelectStereoDrawBuffer', windowPtr, 0);
    Screen('FillRect', windowPtr, [0 0 0]);
    Screen('FillRect', windowPtr, [90 90 90]);
    Screen('TextFont',windowPtr, 'Arial');
    Screen('TextSize',windowPtr, 90);
    DrawFormattedText(windowPtr, endText,'center',50,white);
    Screen('DrawTextures', windowPtr, rocket.texture, [], dstRects);
    DrawFormattedText(windowPtr, endText,'center',50,white,[],flipHorizontal=1);
    Screen('DrawTextures', windowPtr, endRocket.texture, [], endRocket.dstRects);

    % Select right-eye image buffer for drawing:
    Screen('SelectStereoDrawBuffer', windowPtr, 1);
    Screen('FillRect', windowPtr, [0 0 0]);
    Screen('TextFont',windowPtr, 'Arial');
    Screen('TextSize',windowPtr, 90);
    DrawFormattedText(windowPtr, endText,'center',50,white);
    Screen('DrawTextures', windowPtr, rocket.texture, [], dstRects);
    DrawFormattedText(windowPtr, endText,'center',50,white,[],flipHorizontal=1);
    Screen('DrawTextures', windowPtr, endRocket.texture, [], endRocket.dstRects);

    % Now show the end screen
    Screen(windowPtr,'Flip');
  2. smithdanielle created this gist Feb 12, 2015.
    46 changes: 46 additions & 0 deletions expeditionNum.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@
    runNum = input('run number: ');

    % Load rocket image
    rocket.load = imread('rocket2.png');
    rocket.texture = Screen('MakeTexture', windowPtr, rocket.load);
    % Get the size of the image
    [s1, s2, s3] = size(rocket.load);
    % Get the aspect ratio of the image. We need this to maintain the aspect
    % ratio of the image when we draw it different sizes. Otherwise, if we
    % don't match the aspect ratio the image will appear warped / stretched
    aspectRatio = s2 / s1;
    heightScalers= 0.5;
    imageHeights = screenParams.Res(2) .* heightScalers;
    imageWidths = imageHeights .* aspectRatio;
    theRect = [0 0 imageWidths imageHeights];
    dstRects = CenterRectOnPointd(theRect, xcen,...
    ycen+(0.25*imageHeights));

    endText = ['EXPEDITION ', num2str(runNum), ' OF 4 \n COMPLETE'];

    % Prepare the end screen
    % Select left-eye image buffer for drawing:
    Screen('SelectStereoDrawBuffer', windowPtr, 0);
    Screen('FillRect', windowPtr, [0 0 0]);
    Screen('TextFont',windowPtr, 'Arial');
    Screen('TextSize',windowPtr, 90);
    DrawFormattedText(windowPtr, endText,'center',50,white);
    Screen('DrawTextures', windowPtr, rocket.texture, [], dstRects);

    % Select right-eye image buffer for drawing:
    Screen('SelectStereoDrawBuffer', windowPtr, 1);
    Screen('FillRect', windowPtr, [0 0 0]);
    Screen('TextFont',windowPtr, 'Arial');
    Screen('TextSize',windowPtr, 90);
    DrawFormattedText(windowPtr, endText,'center',50,white);
    Screen('DrawTextures', windowPtr, rocket.texture, [], dstRects);

    % Now show the end screen
    Screen(windowPtr,'Flip');
    % Wait for response: should be q key
    keyIsDown = 0;
    while(~keyIsDown || (~keyCode(q) && ~keyCode(escapeKey)))
    [keyIsDown,secs,keyCode] = KbCheck(-3);
    % Returns keyboard status, time, keycode
    end
    keyIsDown = 0;