# Changing position of aperture in DriftDemo2.m

**URL:** <https://psychtoolbox.discourse.group/t/changing-position-of-aperture-in-driftdemo2-m/471>\
**Category:** Uncategorized\
**Created:** [November 7, 2011, 6:45pm UTC](https://psychtoolbox.discourse.group/t/changing-position-of-aperture-in-driftdemo2-m/471 "2011-11-07T18:45:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pikki.hogan](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@pikki.hogan](https://psychtoolbox.discourse.group/u/pikki.hogan)\
**Post date:** [November 7, 2011, 6:45pm UTC](https://psychtoolbox.discourse.group/t/changing-position-of-aperture-in-driftdemo2-m/471/1 "2011-11-07T18:45:01Z")

</div>

Hello,  
  
I'm trying to program a grating oscillating within a circular aperture and I've found the DriftDemo2 in PsychDemos particularly useful. However, I noticed that the dstRect is put in the centre of the screen using CenterRect. I tried changing the position of the aperture by redefining dstRect (i.e. giving new coordinates) but then the screen just turned blank. Would anyone give me some advice what I should have done if I want the drifting grating to appear not the centre, but elsewhere on the screen?   
  
Thank you very much.  
  
Best,  
Pik Ki

---

<div class="post-metadata">

**Author:** ![xrli2002](https://avatars.discourse-cdn.com/v4/letter/x/48db29/32.png) [@xrli2002](https://psychtoolbox.discourse.group/u/xrli2002)\
**Post date:** [November 7, 2011, 9:39pm UTC](https://psychtoolbox.discourse.group/t/changing-position-of-aperture-in-driftdemo2-m/471/2 "2011-11-07T21:39:17Z")

</div>

It should work. Most likely, you messed up the numbers in the rect. They are [left top right bottom]. Topleft cornner is [0 0].  
  
Xiangrui  
  

> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "Pik Ki" \<pkbeckyho@...\> wrote:  
> \>  
> \> Hello,  
> \>   
> \> I'm trying to program a grating oscillating within a circular aperture and I've found the DriftDemo2 in PsychDemos particularly useful. However, I noticed that the dstRect is put in the centre of the screen using CenterRect. I tried changing the position of the aperture by redefining dstRect (i.e. giving new coordinates) but then the screen just turned blank. Would anyone give me some advice what I should have done if I want the drifting grating to appear not the centre, but elsewhere on the screen?   
> \>   
> \> Thank you very much.  
> \>   
> \> Best,  
> \> Pik Ki  
> \>

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [November 8, 2011, 12:24am UTC](https://psychtoolbox.discourse.group/t/changing-position-of-aperture-in-driftdemo2-m/471/3 "2011-11-08T00:24:34Z")

</div>

Indeed.  
E.g., dstRect = CenterRectOnPoint(dstRect, 200, 300);  
insted of CenterRect() line would center the grating to pixel position (x,y) = (200, 300).  
  
"help PsychRects"  
  
-mario  
  

> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "xrli2002" \<xrli2002@...\> wrote:  
> \>  
> \> It should work. Most likely, you messed up the numbers in the rect. They are [left top right bottom]. Topleft cornner is [0 0].  
> \>   
> \> Xiangrui  
> \>   
> \> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "Pik Ki" \<pkbeckyho@\> wrote:  
> \> \>  
> \> \> Hello,  
> \> \>   
> \> \> I'm trying to program a grating oscillating within a circular aperture and I've found the DriftDemo2 in PsychDemos particularly useful. However, I noticed that the dstRect is put in the centre of the screen using CenterRect. I tried changing the position of the aperture by redefining dstRect (i.e. giving new coordinates) but then the screen just turned blank. Would anyone give me some advice what I should have done if I want the drifting grating to appear not the centre, but elsewhere on the screen?   
> \> \>   
> \> \> Thank you very much.  
> \> \>   
> \> \> Best,  
> \> \> Pik Ki  
> \> \>  
> \>

---

<div class="post-metadata">

**Author:** ![pikki.hogan](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@pikki.hogan](https://psychtoolbox.discourse.group/u/pikki.hogan)\
**Post date:** [November 7, 2011, 11:38pm UTC](https://psychtoolbox.discourse.group/t/changing-position-of-aperture-in-driftdemo2-m/471/4 "2011-11-07T23:38:43Z")

</div>

Hi Xiangrui,  
  
Thanks for your reply. That's what I thought as well but I'm pretty sure the coordinates I entered are valid...  
  
Best,  
Pik Ki   
  

> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "xrli2002" \<xrli2002@...\> wrote:  
> \>  
> \> It should work. Most likely, you messed up the numbers in the rect. They are [left top right bottom]. Topleft cornner is [0 0].  
> \>   
> \> Xiangrui  
> \>   
> \> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "Pik Ki" \<pkbeckyho@\> wrote:  
> \> \>  
> \> \> Hello,  
> \> \>   
> \> \> I'm trying to program a grating oscillating within a circular aperture and I've found the DriftDemo2 in PsychDemos particularly useful. However, I noticed that the dstRect is put in the centre of the screen using CenterRect. I tried changing the position of the aperture by redefining dstRect (i.e. giving new coordinates) but then the screen just turned blank. Would anyone give me some advice what I should have done if I want the drifting grating to appear not the centre, but elsewhere on the screen?   
> \> \>   
> \> \> Thank you very much.  
> \> \>   
> \> \> Best,  
> \> \> Pik Ki  
> \> \>  
> \>

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [November 8, 2011, 1:07pm UTC](https://psychtoolbox.discourse.group/t/changing-position-of-aperture-in-driftdemo2-m/471/5 "2011-11-08T13:07:45Z")

</div>

Nope, Xiangrui is right, it will work if you don't make a mistake. I assume your psychtoolbox is not outdated by years or something else is seriously broken on your computer.  
  
-mario  
  

> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "Pik Ki" \<pkbeckyho@...\> wrote:  
> \>  
> \> Hi Xiangrui,  
> \>   
> \> Thanks for your reply. That's what I thought as well but I'm pretty sure the coordinates I entered are valid...  
> \>   
> \> Best,  
> \> Pik Ki   
> \>   
> \> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "xrli2002" \<xrli2002@\> wrote:  
> \> \>  
> \> \> It should work. Most likely, you messed up the numbers in the rect. They are [left top right bottom]. Topleft cornner is [0 0].  
> \> \>   
> \> \> Xiangrui  
> \> \>   
> \> \> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "Pik Ki" \<pkbeckyho@\> wrote:  
> \> \> \>  
> \> \> \> Hello,  
> \> \> \>   
> \> \> \> I'm trying to program a grating oscillating within a circular aperture and I've found the DriftDemo2 in PsychDemos particularly useful. However, I noticed that the dstRect is put in the centre of the screen using CenterRect. I tried changing the position of the aperture by redefining dstRect (i.e. giving new coordinates) but then the screen just turned blank. Would anyone give me some advice what I should have done if I want the drifting grating to appear not the centre, but elsewhere on the screen?   
> \> \> \>   
> \> \> \> Thank you very much.  
> \> \> \>   
> \> \> \> Best,  
> \> \> \> Pik Ki  
> \> \> \>  
> \> \>  
> \>

---

<div class="post-metadata">

**Author:** ![pikki.hogan](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@pikki.hogan](https://psychtoolbox.discourse.group/u/pikki.hogan)\
**Post date:** [November 8, 2011, 12:05pm UTC](https://psychtoolbox.discourse.group/t/changing-position-of-aperture-in-driftdemo2-m/471/6 "2011-11-08T12:05:27Z")

</div>

Thanks Mario, that worked! :D   
  

> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "Pik Ki" \<pkbeckyho@...\> wrote:  
> \>  
> \> Hi Xiangrui,  
> \>   
> \> Thanks for your reply. That's what I thought as well but I'm pretty sure the coordinates I entered are valid...  
> \>   
> \> Best,  
> \> Pik Ki   
> \>   
> \> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "xrli2002" \<xrli2002@\> wrote:  
> \> \>  
> \> \> It should work. Most likely, you messed up the numbers in the rect. They are [left top right bottom]. Topleft cornner is [0 0].  
> \> \>   
> \> \> Xiangrui  
> \> \>   
> \> \> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "Pik Ki" \<pkbeckyho@\> wrote:  
> \> \> \>  
> \> \> \> Hello,  
> \> \> \>   
> \> \> \> I'm trying to program a grating oscillating within a circular aperture and I've found the DriftDemo2 in PsychDemos particularly useful. However, I noticed that the dstRect is put in the centre of the screen using CenterRect. I tried changing the position of the aperture by redefining dstRect (i.e. giving new coordinates) but then the screen just turned blank. Would anyone give me some advice what I should have done if I want the drifting grating to appear not the centre, but elsewhere on the screen?   
> \> \> \>   
> \> \> \> Thank you very much.  
> \> \> \>   
> \> \> \> Best,  
> \> \> \> Pik Ki  
> \> \> \>  
> \> \>  
> \>
