We have all seen Tag Clouds on blogs and websites. If you haven't seen one, well it consists of all the tags you have given to posts on your websites arranged in a 3D cloud which rotates when you point to a tag and brings it into focus. Today we'll see how to build the same using jQuery, which is a Javascipt framework.

Well the HTML part is pretty easy to write. All we need is the list of tags in a div. The next thing we want to work on is the stylesheet. Or maybe you can include the styles in the HTML file itself. The anchor links should have position: absolute. This way the jQuery can give it x and y co-ordinates and the links will just go and sit there. Also we need to give a height and width of the div wrapper. Now, give the wrapper position:relative to keep the links inside the wrapper. (optional)

Whats left now? Yes, the most important part, jQuery. We are going to use some 3D trigonometry here. First we write the mouse event. We figure out how far the mouse is away from the center and assign it to a variable that controls the speed of the scrolling list. After that we step through each element in our list and give each one a place on the 3D circle. A for loop governs this and evenly assigns an angle to each element. (1st = 0 degrees, 2nd = 5 degrees, 3rd = 10 degrees, etc) We'll animate it now.

We use setInterval to call our render function again and again. The render function goes through each element and decides where and how it should be displayed. The trigonometry creates a set of numbers that when plotted on a graph look like a wave. If we apply these to the size of the text, it appears to go back and forth in space. If we apply these numbers to the y, this will give you the appearance that the text is going around in a circle. Try to change the values to understand better.