Guest User

Untitled

a guest
Apr 26th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 KB | None | 0 0
  1. clear all
  2.  
  3. HideCursor;
  4. %%
  5.  
  6. %0 for one monitor, 1 for two or more monitors
  7. WinNum = 0;
  8.  
  9. %Determine Monitor Resolution
  10. ScreenRes = Screen('Resolution', WinNum);
  11. xCenter = (ScreenRes.width)/2;
  12. yCenter = (ScreenRes.height)/2;
  13.  
  14. Background = [100,100,100]; % Higher numbers are lighter
  15. BackgroundIndex = 100;
  16.  
  17. white = [255 255 255];
  18. black = [0 0 0];
  19. Grey_LowC = [139 139 139]; % 25 percent of the distance between white and the background grey, rounded up.
  20. red = [255 0 0];%For testing purposes and feedback.
  21. green = [0 255 0];
  22.  
  23. InstructionTxtSize = 18;
  24. StimTextSize = 50;
  25.  
  26. w = Screen('OpenWindow',WinNum,Background);
  27. %%
  28.  
  29. %Example 1 Parameters
  30. InstructionRect = ones(ceil(ScreenRes.width), ceil(ScreenRes.height)).* BackgroundIndex;
  31. InstructionTexture = Screen('MakeTexture', w, InstructionRect);
  32. Screen('TextSize', InstructionTexture, StimTextSize);
  33. Screen('TextFont', InstructionTexture, 'Anonymous Pro');
  34. LetAdj = 10;%add spaces between letters
  35. TxtColor1 = red;
  36. TxtColor2 = white;
  37. LocLet = 'A';
  38.  
  39. %Global X
  40. [~,~, X_textbounds4] = DrawFormattedText(InstructionTexture, LocLet, 'center', 'center', TxtColor1,[],[],[],[.75] );
  41. X_Diff = X_textbounds4(3)- X_textbounds4(1) + LetAdj;
  42. Y_Diff = X_textbounds4(4)- X_textbounds4(2) + LetAdj;
  43. %Top of X
  44. [~,~, X_textbounds3L] = DrawFormattedText(InstructionTexture, LocLet, X_textbounds4(1)-(X_Diff*.75), X_textbounds4(2)-Y_Diff, TxtColor2,[],[],[],[.75]);
  45. [~,~, X_textbounds2L] = DrawFormattedText(InstructionTexture, LocLet, X_textbounds3L(1)-(X_Diff*.75), X_textbounds3L(2)-Y_Diff, TxtColor1,[],[],[],[.75]);
  46. [~,~, X_textbounds1L] = DrawFormattedText(InstructionTexture, LocLet, X_textbounds2L(1)-(X_Diff*.75), X_textbounds2L(2)-Y_Diff, TxtColor2,[],[],[],[.75]);
  47. [~,~, X_textbounds3R] = DrawFormattedText(InstructionTexture, LocLet, X_textbounds4(1)+(X_Diff*.75), X_textbounds4(2)-Y_Diff, TxtColor2,[],[],[],[.75] );
  48. [~,~, X_textbounds2R] = DrawFormattedText(InstructionTexture, LocLet, X_textbounds3R(1)+(X_Diff*.75 ), X_textbounds3R (2)-Y_Diff, TxtColor1,[],[],[],[.75] );
  49. [~,~, X_textbounds1R] = DrawFormattedText(InstructionTexture, LocLet, X_textbounds2R(1)+(X_Diff*.75 ), X_textbounds2R (2)-Y_Diff, TxtColor2,[],[],[],[.75] );
  50. %Bottom of X
  51. [~,~, X_textbounds5L] = DrawFormattedText(InstructionTexture, LocLet, X_textbounds4(1)-(X_Diff*.75), X_textbounds4(2)+Y_Diff, TxtColor2,[],[],[],[.75]);
  52. [~,~, X_textbounds6L] = DrawFormattedText(InstructionTexture, LocLet, X_textbounds5L(1)-(X_Diff*.75), X_textbounds5L(2)+Y_Diff, TxtColor1,[],[],[],[.75]);
  53. [~,~, X_textbounds7L] = DrawFormattedText(InstructionTexture, LocLet, X_textbounds6L(1)-(X_Diff*.75), X_textbounds6L(2)+Y_Diff, TxtColor2 ,[],[],[],[.75]);
  54. [~,~, X_textbounds5R] = DrawFormattedText(InstructionTexture, LocLet, X_textbounds4(1)+(X_Diff*.75), X_textbounds4(2)+Y_Diff, TxtColor2,[],[],[],[.75]);
  55. [~,~, X_textbounds6R] = DrawFormattedText(InstructionTexture, LocLet, X_textbounds5R(1)+(X_Diff*.75), X_textbounds5R (2)+Y_Diff, TxtColor1 ,[],[],[],[.75] );
  56. [~,~, X_textbounds7R] = DrawFormattedText(InstructionTexture, LocLet, X_textbounds6R(1)+(X_Diff*.75), X_textbounds6R (2)+Y_Diff, TxtColor2 ,[],[],[],[.75] );
  57.  
  58. SourceRect = [X_textbounds1L(1)-(LetAdj*7),X_textbounds1L(2)-(LetAdj*7),X_textbounds7R(3)+(LetAdj*7), X_textbounds7R(4)+ (LetAdj*7)];
  59. X_Dim = SourceRect(3)-SourceRect(1);
  60. Y_Dim = SourceRect(4)-SourceRect(2);
  61.  
  62. DestinationRect = [xCenter-(X_Dim/2),yCenter-(Y_Dim/2),xCenter+(X_Dim/2),yCenter+(Y_Dim/2)];
  63.  
  64. Screen('DrawTexture', w, InstructionTexture, SourceRect, DestinationRect);
  65. Screen('Flip',w);
  66. KbWait([], 2);
  67.  
  68. Screen('CloseAll');
Add Comment
Please, Sign In to add comment