makingoval.m 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. % Clear the workspace and the screen
  2. sca;
  3. close all;
  4. clearvars;
  5. % Here we call some default settings for setting up Psychtoolbox
  6. % PsychDefaultSetup(2);
  7. backgroundColor = 20;
  8. Screen('Preference', 'SkipSyncTests', 1) %%% IMPORTANT!! REMOVE THIS LINE WHEN RUNNING THE TASK
  9. % Get the screen numbers
  10. screens = Screen('Screens');
  11. % Draw to the external screen if avaliable
  12. screenNumber = max(screens);
  13. % Define black and white
  14. white = WhiteIndex(screenNumber);
  15. black = BlackIndex(screenNumber);
  16. % Open an on screen window
  17. [window, rect] = Screen('OpenWindow', screenNumber,backgroundColor,[],[],2);
  18. % Get the size of the on screen window
  19. [screenXpixels, screenYpixels] = Screen('WindowSize', window);
  20. W=rect(RectRight); % screen width
  21. H=rect(RectBottom); % screen height
  22. % Get the centre coordinate of the window
  23. [xCenter, yCenter] = RectCenter(rect);
  24. % Make a base Rect
  25. baseRect1 = [0 0 W/2 W/2];
  26. baseRect2 = [0 0 W/2.5 W/2.5];
  27. baseRect3 = [0 0 W/3.5 W/3.5];
  28. baseRect4 = [0 0 W/6 W/6];
  29. baseRect5 = [0 0 W/15 W/15];
  30. % For Ovals we set a miximum diameter up to which it is perfect for
  31. maxDiameter1 = max(baseRect1) * 1.01;
  32. maxDiameter2 = max(baseRect2) * 1.01;
  33. maxDiameter3 = max(baseRect3) * 1.01;
  34. maxDiameter4 = max(baseRect4) * 1.01;
  35. maxDiameter5 = max(baseRect5) * 1.01;
  36. % Center the rectangle on the centre of the screen
  37. centeredRect1 = CenterRectOnPointd(baseRect1, xCenter, yCenter);
  38. centeredRect2 = CenterRectOnPointd(baseRect2, xCenter, yCenter);
  39. centeredRect3 = CenterRectOnPointd(baseRect3, xCenter, yCenter);
  40. centeredRect4 = CenterRectOnPointd(baseRect4, xCenter, yCenter);
  41. centeredRect5 = CenterRectOnPointd(baseRect5, xCenter, yCenter);
  42. % Set the color for obbball pings
  43. rectColor_odd{1} = [250 0 0];
  44. rectColor_odd{2} = [245 245 245];
  45. rectColor_odd{3} = [250 0 0];
  46. rectColor_odd{4} = [245 245 245];
  47. rectColor_odd{5} = [250 0 0];
  48. % Set the color for pings
  49. rectColor{1} = [140 140 140];
  50. rectColor{2} = [245 245 245];
  51. rectColor{3} = [140 140 140];
  52. rectColor{4} = [245 245 245];
  53. rectColor{5} = [140 140 140];
  54. % Draw the rect to the screen
  55. Screen('FillOval', window, rectColor_s{1}, centeredRect1, maxDiameter1);
  56. Screen('FillOval', window, rectColor_s{2}, centeredRect2, maxDiameter2);
  57. Screen('FillOval', window, rectColor_s{3}, centeredRect3, maxDiameter3);
  58. Screen('FillOval', window, rectColor_s{4}, centeredRect4, maxDiameter4);
  59. Screen('FillOval', window, rectColor_s{5}, centeredRect5, maxDiameter5);
  60. % Flip to the screen
  61. Screen('Flip', window);
  62. % Wait for a key press
  63. KbStrokeWait;
  64. % Clear the screen
  65. sca;