11,415,390 members (89,639 online)

# A Thumb Rotator

, 2 Dec 2008 CPOL
 Rate this:
A fast and furious - one step far from - screensaver application.

## Introduction

First of all, remember, this is not the best way to make a Thumb Rotator!!! And now, let's see what a Thumb Rotator is. It is a program which tells you where your pictures are, and it will show them by rotating them slowly around an ellipse, pretending they are on a 3D space, simulating a mirror on the floor, using fake lighting algorithms...

In this article, there is no DirectX, OpenGL, or anything like them.

## First step

First of all, we will arrange the images around an ellipse. To obtain the - let's say - 10 points, with x0, y0 for the center of the screen, and R1 and R2 as great and little radius (it's an ellipse!):

```for (int angle=0; angle<360; angle+=36)
{
int x=x0+R1*cos(dAngle);
int y=y0-R2*sin(dAngle);
// do something with the x,y - for example, draw the image (scaled!)
}```

## Animate!

To animate, simply use a timer. And for every step, add some increment to the angle of every image. Take a look at the code in the zip file!

Two simple tricks: first, draw images from the top Y position to the bottom. In an ellipse-arranged-thumb-rotator, this works fine. Second, draw scaled from the top Y position to the bottom. The images on the top have to be smaller than the images on the bottom.

1. Create a copy of the image
2. Make it upside-down
3. For every pixel in the copied image, change the alpha value according to this rule, scaling linear: 255 to the top (no transparence), 0 to the bottom (maximum transparence)

Make images on the top darker. Simply draw a black, semi-transparent rectangle on them!!!

## Interact with the mouse

Monitor your mouse while it is being moved!. If it's moving near the center, there should be no rotation. When the mouse is on the left, make the rotation from left to right. When the mouse is on the right, make the rotation in the reverse direction.

Every time you draw an image, remember its position. So, when the mouse is moving, you can perform the "hit test". The "under mouse pointer" image has full light, no darker effect on it (remember the previous paragraph).

That's all! Have fun. Remember, this is not the best way to do it, but it works!

## Share

Software Developer (Senior) Selex ES
Italy
Hi
I was born in 1970 (Augusta - Italy).
I live in Taranto - Italy.
I work in Taranto - Italy.
I like computer science!!!
That's all!

 First PrevNext
 My vote of 5 IKalai4-Apr-13 20:44 IKalai 4-Apr-13 20:44
 Thank you futurejo27-Jul-09 8:05 futurejo 27-Jul-09 8:05
 two problems francisngl15-May-09 15:51 francisngl 15-May-09 15:51
 Title needs work. muzzdeni5-Mar-09 16:18 muzzdeni 5-Mar-09 16:18
 Change the title kosmonafta9-Dec-08 22:23 kosmonafta 9-Dec-08 22:23
 cool tigerfCPRJ8-Dec-08 13:13 tigerfCPRJ 8-Dec-08 13:13
 DLL to be integrated? Hegemon8-Dec-08 8:01 Hegemon 8-Dec-08 8:01
 Nice code johannesnestler5-Dec-08 6:51 johannesnestler 5-Dec-08 6:51
 Nice Dhimant Trivedi5-Dec-08 1:03 Dhimant Trivedi 5-Dec-08 1:03
 The article needs a better title PIEBALDconsult3-Dec-08 6:08 PIEBALDconsult 3-Dec-08 6:08
 Last Visit: 31-Dec-99 19:00     Last Update: 27-Apr-15 15:33 Refresh 12 Next »