For those of you who are Code geeks like me, or if you're curious what's happening, I spaced it out to be more readable.
javascript
:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.images; DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5}R++}setInterval('A()',5); void(0);
becomes...
Code:
javascript:
R=0;
x1=.1;
y1=.05;
x2=.25;
y2=.24;
x3=1.6;
y3=.24;
x4=300;
y4=200;
x5=300;
y5=200;
DI=document.images;
DIL=DI.length;
function A()
{
for(i=0; i-DIL; i++)
{
DIS=DI[ i ].style;
DIS.position='absolute';
DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5;
DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5
}
R++
}
setInterval('A()',5);
void(0);
Here's basically what it does:
- setInterval executes function A() every 5 ms.
- During A(), the browser loops through DI, which holds a list of all the images with in a page.
- DIS gets an image from the DI, sequentially, until they have all been selected.
- The absolutely positioned left and top values for the image is set according to a Cos/sin equation with the originally seeded variables.
- The "Spinning" effect is generated by R, it is incremented by 1 each time a new image is selected.
For some fun, try manipulating R; it effects the speed of rotation;
If you make R increment by 0.05 instead of 1, you get:
javascript
:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.images; DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5}R+=0.05}setInterval('A()',5); void(0);
Sloooooooowwwwwwwwwwww rotation.
If you make R 2 you get:
javascript
:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.images; DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5}R+=2}setInterval('A()',5); void(0);
Speedy!
.. I have too much free time on my hands.
