Builder maintains a variable called t
that represents the time in seconds since the start of the routine. So you can easily animate stimuli by incorporating t
in a formula for their size or position or whatever.
e.g. if you wanted a square stimulus to grow in size from 0 pixels at the start of the routine, at a rate of 50 pixels per second, then you would simply put this in the size field:
t * 50
and set the size field to update on every frame (typically 60 Hz). i.e. at the start of the trial, t == 0
, so the stimulus is invisible. At t == 1.0
, it is 50 pixels in size, at t == 2.0
, it is 100 pixels in size, and so on.
If the stimulus was twice as wide as it was tall, then you would need to specify the size in both axes, in a list:
[t * 50 * 2, t * 50]
In your case, you want to specify a starting size and then have it grow after a certain point in time. Here we can make use of boolean logic, by comparing the current value of t
to some specified start time. If t
is less than that value, the expression will be False
and evaluate to zero, so the growth factor won’t apply. If t
is greater than that value, the expression evaluates to True
or 1, so the factor will be added to the start value. e.g.
100 + (t > 2.0) * (10 * (t - 2.0))
i.e. in this case, the stimulus starts with dimensions of 100 × 100 pixels. While t
< 2.0 seconds, the second expression evaluates to False
, or 0
, so the size stays constant. After 2.0 seconds have elapsed, the second term now equals 1, so the size grows by 10 pixels per second.
Hope that makes sense.