|
1 | 1 | function cfg = apertureTexture(action, cfg, thisEvent) |
2 | | - |
| 2 | + |
3 | 3 | transparent = [0 0 0 0]; |
4 | | - |
| 4 | + |
5 | 5 | switch action |
6 | | - |
| 6 | + |
7 | 7 | case 'init' |
8 | | - |
9 | | - % we take the screen height as maximum aperture width if not |
10 | | - % specified. |
11 | | - if ~isfield(cfg.aperture, 'width') || isempty(cfg.aperture.width) |
12 | | - cfg.aperture.width = cfg.screen.winRect(4) / cfg.screen.ppd; |
| 8 | + |
| 9 | + switch cfg.aperture.type |
| 10 | + |
| 11 | + case 'circle' |
| 12 | + % we take the screen height as maximum aperture width if not |
| 13 | + % specified. |
| 14 | + if ~isfield(cfg.aperture, 'width') || isempty(cfg.aperture.width) |
| 15 | + cfg.aperture.width = cfg.screen.winRect(4) / cfg.screen.ppd; |
| 16 | + end |
| 17 | + cfg.aperture = degToPix('width', cfg.aperture, cfg); |
13 | 18 | end |
14 | | - cfg.aperture = degToPix('width', cfg.aperture, cfg); |
15 | | - |
| 19 | + |
16 | 20 | cfg.aperture.texture = Screen('MakeTexture', cfg.screen.win, ... |
17 | 21 | cfg.color.background(1) * ones(cfg.screen.winRect([4 3]))); |
18 | | - |
| 22 | + |
19 | 23 | case 'make' |
20 | | - |
| 24 | + |
| 25 | + xCenter = cfg.screen.center(1); |
| 26 | + yCenter = cfg.screen.center(2); |
| 27 | + |
21 | 28 | switch cfg.aperture.type |
22 | | - |
| 29 | + |
23 | 30 | case 'none' |
24 | | - |
| 31 | + |
25 | 32 | Screen('Fillrect', cfg.aperture.texture, transparent); |
26 | | - |
| 33 | + |
27 | 34 | case 'circle' |
28 | | - |
| 35 | + |
29 | 36 | diameter = cfg.aperture.widthPix; |
30 | | - |
31 | | - xPos = cfg.screen.center(1); |
32 | | - yPos = cfg.screen.center(2); |
| 37 | + |
33 | 38 | if isfield(cfg.aperture, 'xPosPix') |
34 | | - xPos = cfg.screen.center(1) + cfg.aperture.xPosPix; |
| 39 | + xCenter = cfg.screen.center(1) + cfg.aperture.xPosPix; |
35 | 40 | end |
36 | 41 | if isfield(cfg.aperture, 'yPosPix') |
37 | | - yPos = cfg.screen.center(2) + cfg.aperture.yPosPix; |
| 42 | + yCenter = cfg.screen.center(2) + cfg.aperture.yPosPix; |
38 | 43 | end |
39 | | - |
| 44 | + |
40 | 45 | Screen('FillOval', cfg.aperture.texture, transparent, ... |
41 | 46 | CenterRectOnPoint([0 0 repmat(diameter, 1, 2)], ... |
42 | | - xPos, yPos)); |
| 47 | + xCenter, yCenter)); |
| 48 | + |
| 49 | + case 'ring' |
| 50 | + |
| 51 | + Screen('Fillrect', cfg.aperture.texture, cfg.color.background); |
| 52 | + |
| 53 | + Screen('FillOval', cfg.aperture.texture, transparent, ... |
| 54 | + CenterRectOnPoint( ... |
| 55 | + [0 0 repmat(cfg.ring.outerRimPix, 1, 2)], ... |
| 56 | + xCenter, yCenter)); |
| 57 | + |
| 58 | + Screen('FillOval', cfg.aperture.texture, [cfg.color.background 255], ... |
| 59 | + CenterRectOnPoint( ... |
| 60 | + [0 0 repmat(cfg.ring.innerRimPix, 1, 2)], ... |
| 61 | + xCenter, yCenter)); |
| 62 | + |
| 63 | + case 'wedge' |
| 64 | + |
| 65 | + Screen('Fillrect', cfg.aperture.texture, cfg.color.background); |
| 66 | + |
| 67 | + Screen('FillArc', cfg.aperture.texture, transparent, ... |
| 68 | + CenterRect( ... |
| 69 | + [0 0 repmat(cfg.stimRect(4), 1, 2)], ... |
| 70 | + cfg.screen.winRect), ... |
| 71 | + thisEvent.angle, ... % start angle |
| 72 | + cfg.aperture.width); % arc angle |
| 73 | + |
43 | 74 |
|
44 | 75 | otherwise |
45 | 76 |
|
46 | 77 | error('unknown aperture type: %s.', cfg.aperture.type); |
47 | | - |
| 78 | + |
48 | 79 | end |
49 | | - |
| 80 | + |
50 | 81 | case 'draw' |
51 | | - |
| 82 | + |
52 | 83 | Screen('DrawTexture', cfg.screen.win, cfg.aperture.texture); |
53 | | - |
| 84 | + |
54 | 85 | % Screen('DrawTexture', cfg.screen.win, apertureTexture, ... |
55 | 86 | % cfg.screen.winRect, cfg.screen.winRect, current.apertureAngle - 90); |
56 | | - |
| 87 | + |
57 | 88 | end |
58 | | - |
| 89 | + |
59 | 90 | end |
0 commit comments