# Animation in Windows

**URL:** <https://psychtoolbox.discourse.group/t/animation-in-windows/1885>\
**Category:** Uncategorized\
**Created:** [October 24, 2003, 11:11pm UTC](https://psychtoolbox.discourse.group/t/animation-in-windows/1885 "2003-10-24T23:11:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![adarsh\_golikeri](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@adarsh\_golikeri](https://psychtoolbox.discourse.group/u/adarsh_golikeri)\
**Post date:** [October 24, 2003, 11:11pm UTC](https://psychtoolbox.discourse.group/t/animation-in-windows/1885/1 "2003-10-24T23:11:29Z")

</div>

Hi all,  
  
I am running MATLAB Version 6.0(R12) and Psychtoolbox version 2.5 on   
a Win98 machine. My processor is a Pentium II 300MHZ, with 128Mb RAM.  
  
I want to create animation using the Psychtoolbox. Basically, I want   
to create a shaded circle (using 'FillArc') and I want this image to   
rotate at different speeds on the screen.  
  
The procedure I followed is standard (same as that shown in   
MovieDemo.m). i.e I assign an OffScreenWindow of size [0 0 200 200]   
and then create the images of the circle at various points inside   
this OffScreenWindow. I then playback this sequence using 'Rush'   
and 'Prioritylevel'.   
  
My questions :  
  
1. Have I understood the concept of OffScreenWindow right ? i.e do I   
have to create my entire animation sequence within the limits of the   
[0 0 200 200] window ?  
  
2. If so, then I am very much limited by memory, because the moment I   
try to increase the size of this beyond 200, the program stops   
working.  
  
3. Can I try this approach -\> When I am creating the images of this   
circle at different points, can I store EACH of the images into a   
SEPARATE OffScreenWindow (as opposed to ONE OffScreen Window in   
MoviveDemo.m), whose co-ordinates would be exactly that of the circle   
itself ? In this way, I won't be limited to creating animations in   
the 200x200 box. Instead, I can show each OffScreenWindow at   
different positions and acieve the deisred animation.  
  
Please let me know if I have made myself clear. Here's the core   
portion of the code, if that helps :  
  
====================================================================  
%Generate co-ordinates of the circluar path  
angle = linspace(0,2\*pi,200);  
x = 50\*cos(angle);  
y = 50\*sin(angle);  
  
%Create 200 images of the circle at different positions of this  
%circluar path  
for i=1:200  
 r=[20+x(i) 20+y(i) 50+x(i) 50+y(i)];  
 w(i)=SCREEN(window,'OpenOffscreenWindow',[],rect,pixelSize);  
 SCREEN(w(i),'FillArc',black,r,0,360);  
end  
  
% Show the movie  
loop = {  
 'for i=1:speed:200'  
 ' rect2=[20+x1+x(i) 20+y1+y(i) 50+x1+x(i) 50+y1+y(i)];'  
% x1 = 400, y1 = 260 -\> To get the result on the center of the screen  
 ' rect = rect2 - [x1 y1 x1 y1];'  
 ' Screen(''CopyWindow'',w(i),window,rect,rect2);'  
 ' Screen(window,''WaitBlanking'');'  
 ' Screen(window,''FillRect'',white,rect2);'  
 ' Screen(w(i),''Close'');'  
 'end'  
};  
  
HideCursor;  
Rush(loop,priorityLevel);  
  
====================================================================  
  
Thanks a lot,  
  
Adarsh
