My First Post      My Facebook Profile      My MeOnShow Profile      W3LC Facebook Page      Learners Consortium Group      Job Portal      Shopping @Yeyhi.com

Pages










Friday, May 14, 2010

Cool Trick with website images!!!

Mathematics in itself is a fun and sheer joy if you are able to see through its beauty.

I feel that as you keep on realizing the application of mathematics and its ideas in different branches of science, philosophy and technology, you will start enjoying every aspects of it. Especially, I find the number science and the effects of simple functions on the ranges that a domain of inputs can bring as amazing. 

Let me show a simple trick using Javascript. It will use a great mathematical trick. Please feel free to dive into it if you want.

Remember that JavaScript is a popular scripting language. It powers the most popular Web 2.0 applications with a combination of web development technique called AJAX.
However, Javascript can and is very well employed to create stunning effects in Web pages.

In addition it can also be copied and pasted in the address bar of a web browser. This will run the javascript code in the address bar over the webpage/document already loaded in the browser.

Lets stop gambling with words. Some men (women too!) really need action. So, here it goes...

Steps:
1. Open a web page with some pictures/images
You may even try with this webpage itself (so no need to open new)
or, You may also open http://images.google.com and search for whatever you like eg. cartoon.
2. Copy and paste the following code in the address bar of your internet browser.

############################################
javascript:R=0; it_discussions=5;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 mohdajf(){for(i=0; i-DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.mkssddddddddddd=Math.sin(R*x1+i*x2+x3)*x4+x5; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5}R++}setInterval('mohdajf()',it_discussions); void(0);
#############################################

Voila!! The pictures have started dancing!
This is a single manifest of the power of Mathematics used with Javascript!

It is evident that there can be much of fun with this one line of code.

In case, you modify the code to create yet another stunning cool image motions, please share it on IT-Discussions Blog.

1 comment: