Skip to content

Commit 6d73c93

Browse files
committed
move dev and template material in separate folder
1 parent cd2357b commit 6d73c93

File tree

1 file changed

+15
-23
lines changed

1 file changed

+15
-23
lines changed

devSandbox.m renamed to dev/devSandbox.m

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,8 @@
2323
% Init the structure that will contain PTB setup
2424
cfg = struct;
2525

26-
% Set some colors to be choosen as background
27-
cfg.white = [255 255 255];
28-
cfg.black = [0 0 0];
29-
cfg.grey = mean([cfg.black; cfg.white]);
30-
3126
% Set the PTB window background manually
32-
cfg.backgroundColor = cfg.grey;
27+
cfg.color.background = [127 127 27];
3328

3429
% Init PTB, see the Sub-Functions below
3530
cfg = devSandbox_initPTB(cfg);
@@ -40,7 +35,7 @@
4035
% -------------------------------------------------------------------------
4136

4237
% Define black and white
43-
white = WhiteIndex(cfg.screen);
38+
white = WhiteIndex(cfg.screen.idx);
4439
grey = white / 2;
4540
inc = white - grey;
4641

@@ -95,7 +90,7 @@
9590
mask(:, :, 2) = grating .* contrast;
9691

9792
% Make our grating mask texture
98-
gratingMaskTex = Screen('MakeTexture', cfg.win, mask);
93+
gratingMaskTex = Screen('MakeTexture', cfg.screen.win, mask);
9994

10095
% Make a black and white noise mask half the size of our grating. This will
10196
% be scaled upon drawing to make a "chunky" noise texture which our grating
@@ -104,15 +99,15 @@
10499
noise = rand(round(visibleSize / 2)) .* white;
105100

106101
% Make our noise texture
107-
noiseTexture = Screen('MakeTexture', cfg.win, noise);
102+
noiseTexture = Screen('MakeTexture', cfg.screen.win, noise);
108103

109104
% Make a destination rectangle for our textures and center this on the
110105
% screen
111106
dstRect = [0 0 visibleSize visibleSize];
112-
dstRect = CenterRect(dstRect, cfg.winRect);
107+
dstRect = CenterRect(dstRect, cfg.screen.winRect);
113108

114109
% Calculate the wait duration
115-
waitDuration = waitframes * cfg.ifi;
110+
waitDuration = waitframes * cfg.screen.ifi;
116111

117112
% Recompute pixPerCycle, this time without the ceil() operation from above.
118113
% Otherwise we will get wrong drift speed due to rounding errors
@@ -123,7 +118,7 @@
123118
shiftPerFrame = cyclesPerSecond * pixPerCycle * waitDuration;
124119

125120
% Sync us to the vertical retrace
126-
vbl = Screen('Flip', cfg.win);
121+
vbl = Screen('Flip', cfg.screen.win);
127122

128123
% Set the frame counter to zero, we need this to 'drift' our grating
129124
frameCounter = 0;
@@ -142,13 +137,13 @@
142137
srcRect = [xoffset 0 xoffset + visibleSize visibleSize];
143138

144139
% Draw noise texture to the screen
145-
Screen('DrawTexture', cfg.win, noiseTexture, [], dstRect, []);
140+
Screen('DrawTexture', cfg.screen.win, noiseTexture, [], dstRect, []);
146141

147142
% Draw grating mask
148-
Screen('DrawTexture', cfg.win, gratingMaskTex, srcRect, dstRect, []);
143+
Screen('DrawTexture', cfg.screen.win, gratingMaskTex, srcRect, dstRect, []);
149144

150145
% Flip to the screen on the next vertical retrace
151-
vbl = Screen('Flip', cfg.win, vbl + (waitframes - 0.5) * cfg.ifi);
146+
vbl = Screen('Flip', cfg.screen.win, vbl + (waitframes - 0.5) * cfg.screen.ifi);
152147

153148
end
154149

@@ -182,22 +177,19 @@
182177
PsychDefaultSetup(2);
183178

184179
% Get the screen numbers and draw to the external screen if avaliable
185-
cfg.screen = max(Screen('Screens'));
180+
cfg.screen.idx = max(Screen('Screens'));
186181

187182
% Open an on screen window
188-
[cfg.win, cfg.winRect] = Screen('OpenWindow', cfg.screen, cfg.backgroundColor);
183+
[cfg.screen.win, cfg.screen.winRect] = Screen('OpenWindow', cfg.screen.idx, cfg.color.background);
189184

190185
% Get the size of the on screen window
191-
[cfg.winWidth, cfg.winHeight] = WindowSize(cfg.win);
186+
[cfg.screen.winWidth, cfg.screen.winHeight] = WindowSize(cfg.screen.win);
192187

193188
% Query the frame duration
194-
cfg.ifi = Screen('GetFlipInterval', cfg.win);
195-
196-
% Get the Center of the Screen
197-
cfg.center = [cfg.winRect(3), cfg.winRect(4)] / 2;
189+
cfg.screen.ifi = Screen('GetFlipInterval', cfg.screen.win);
198190

199191
% Set up alpha-blending for smooth (anti-aliased) lines
200-
Screen('BlendFunction', cfg.win, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
192+
Screen('BlendFunction', cfg.screen.win, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
201193

202194
end
203195

0 commit comments

Comments
 (0)