-
Notifications
You must be signed in to change notification settings - Fork 4
/
ImageEvent.m
38 lines (36 loc) · 1.19 KB
/
ImageEvent.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
classdef ImageEvent < StudyEvent
% StudyEvent subclass for presenting images
properties
%image = []; % image
alpha = []; % alpha layer
tex = []; % texture handle
rect = []; % Psychtoolbox rect
window = []; % window handle
name = 'image';
end
methods
function s = ImageEvent(im,st,varargin)
% Initialise event by populating fields, possibly making texture
sout = varargs2structfields(varargin,s);
for fn = fieldnames(sout)'
s.(fn{1}) = sout.(fn{1});
end
%s.image = im;
s.window = st.window;
if ieNotDefined('alpha')
s.alpha = ones(size(im));
end
% do we need to make texture?
if isempty(s.tex)
s.tex = Screen('MakeTexture',s.window,...
cat(3,im,uint8(255*s.alpha)));
end
end
function call(self)
self.ncalls = self.ncalls+1;
self.time = GetSecs;
% nb we don't flip to allow multiple draws before flip
Screen('DrawTexture',self.window,self.tex,[],self.rect);
end
end
end