|
41 | 41 |
|
42 | 42 | % Define black and white |
43 | 43 | white = WhiteIndex(cfg.screen); |
44 | | -black = BlackIndex(cfg.screen); |
45 | 44 | grey = white / 2; |
46 | 45 | inc = white - grey; |
47 | 46 |
|
|
73 | 72 | % ------------------------------ PLAYGROUND ------------------------------- |
74 | 73 | % ------------------------------------------------------------------------- |
75 | 74 | % Define Half-Size of the grating image. |
76 | | -texsize = gratingSizePix / 2; |
| 75 | +textureSize = gratingSizePix / 2; |
77 | 76 |
|
78 | 77 | % First we compute pixels per cycle rounded to the nearest pixel |
79 | 78 | pixPerCycle = ceil(1 / freqCyclesPerPix); |
|
82 | 81 | freqRad = freqCyclesPerPix * 2 * pi; |
83 | 82 |
|
84 | 83 | % This is the visible size of the grating |
85 | | -visibleSize = 2 * texsize + 1; |
| 84 | +visibleSize = 2 * textureSize + 1; |
| 85 | + |
86 | 86 |
|
87 | 87 | % Define our grating. Note it is only 1 pixel high. PTB will make it a full |
88 | 88 | % grating upon drawing |
89 | | -x = meshgrid(-texsize:texsize + pixPerCycle, 1); |
| 89 | +x = meshgrid(-textureSize:textureSize + pixPerCycle, 1); |
90 | 90 | grating = grey * cos(freqRad*x) + inc; |
91 | 91 |
|
| 92 | + |
92 | 93 | % Make a two layer mask filled with the background colour |
93 | 94 | mask = ones(1, numel(x), 2) * grey; |
94 | 95 |
|
|
98 | 99 | % Make our grating mask texture |
99 | 100 | gratingMaskTex = Screen('MakeTexture', cfg.win, mask); |
100 | 101 |
|
| 102 | + |
101 | 103 | % Make a black and white noise mask half the size of our grating. This will |
102 | 104 | % be scaled upon drawing to make a "chunky" noise texture which our grating |
103 | 105 | % will mask. Note the round function in here. For this demo we are simply |
104 | 106 | % rounding the size to the nearest pixel, leaving PTB to do some scaling. |
105 | 107 | noise = rand(round(visibleSize / 2)) .* white; |
106 | 108 |
|
107 | 109 | % Make our noise texture |
108 | | -noiseTex = Screen('MakeTexture', cfg.win, noise); |
| 110 | +noiseTexture = Screen('MakeTexture', cfg.win, noise); |
| 111 | + |
109 | 112 |
|
110 | 113 | % Make a destination rectangle for our textures and center this on the |
111 | 114 | % screen |
|
143 | 146 | srcRect = [xoffset 0 xoffset + visibleSize visibleSize]; |
144 | 147 |
|
145 | 148 | % Draw noise texture to the screen |
146 | | - Screen('DrawTexture', cfg.win, noiseTex, [], dstRect, []); |
| 149 | + Screen('DrawTexture', cfg.win, noiseTexture, [], dstRect, []); |
147 | 150 |
|
148 | 151 | % Draw grating mask |
149 | 152 | Screen('DrawTexture', cfg.win, gratingMaskTex, srcRect, dstRect, []); |
|
0 commit comments