Moving sine grating texture in aperture

Hi all,

I am trying to write a script that will generate a stationary circular aperture with a moving sine grating texture inside of it. However, the texture needs to be finite, in the sense that all the black bars in the sine grating can move completely outside of the circular aperture, leading to the aperture simply revealing a white background. Does anyone know how I can go about doing this? The pictures below illustrate the kind of effect I am trying to achieve.

frame 1: http://www.screencast.com/t/YWfktFDt
2: http://www.screencast.com/t/yB8zNN13KqID
3: http://www.screencast.com/t/mmUBJbOdEjxG
4: http://www.screencast.com/t/BlEI1DQ5qZl
final: http://www.screencast.com/t/eWhoSRYBUS
Look at DriftingMaskedGratingTutorial after running it, to understand the principle of srcRect and dstRect parameters in Screen('DrawTexture'). Look at DriftDemo2 for code that uses this principle. Tinkering with those should give you the idea how to do this.

You may need to add an alpha channel to the grating texture (just as is done with the mask texture) and then set the transparency value for parts of the texture to zero to make it transparent and show the background. Or simply paint those parts of the grating texture white.

Anyway, it's not difficult.
-mario

--- In psychtoolbox@yahoogroups.com, "rahonavis75" <rahonavis75@...> wrote:
>
> Hi all,
>
> I am trying to write a script that will generate a stationary circular aperture with a moving sine grating texture inside of it. However, the texture needs to be finite, in the sense that all the black bars in the sine grating can move completely outside of the circular aperture, leading to the aperture simply revealing a white background. Does anyone know how I can go about doing this? The pictures below illustrate the kind of effect I am trying to achieve.
>
> frame 1: http://www.screencast.com/t/YWfktFDt
> 2: http://www.screencast.com/t/yB8zNN13KqID
> 3: http://www.screencast.com/t/mmUBJbOdEjxG
> 4: http://www.screencast.com/t/BlEI1DQ5qZl
> final: http://www.screencast.com/t/eWhoSRYBUS
>