Click here to Skip to main content
6,632,966 members and growing! (19,496 online)
Email Password   helpLost your password?
Multimedia » General Graphics » Image Display     Intermediate License: The Code Project Open License (CPOL)

A Thumb Rotator

By Massimiliano Conte

A fast and furious - one step far from - screensaver application.
C#, Windows, .NET, Visual Studio, GDI+, Dev
Version:2 (See All)
Posted:15 Oct 2008
Updated:2 Dec 2008
Views:8,767
Bookmarked:28 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
16 votes for this article.
Popularity: 5.76 Rating: 4.78 out of 5

1

2

3
4 votes, 25.0%
4
12 votes, 75.0%
5

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)
{
   double dAngle=DEGREE_TO_RADIANS(angle);
   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!

Add perspective

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.

Add lighting effect

To draw the shadow/fading/upside-down image on the bottom, simply follow these steps:

  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! :)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Massimiliano Conte


Member
Hi Smile
I was born in 1970 (Augusta - Italy).
I live in Taranto - Italy.
I work in Taranto - Italy.
I like computer science!!!
That's all!
Occupation: Software Developer (Senior)
Company: ElsagDatamat
Location: Italy Italy

Other popular General Graphics articles:

  • A flexible charting library for .NET
    Looking for a way to draw 2D line graphs with C#? Here's yet another charting class library with a high degree of configurability, that is also easy to use.
  • CxImage
    CxImage is a C++ class to load, save, display, transform BMP, JPEG, GIF, PNG, TIFF, MNG, ICO, PCX, TGA, WMF, WBMP, JBG, J2K images.
  • 3D Pie Chart
    A class library for drawing 3D pie charts.
  • Barcode Image Generation Library
    This library was designed to give an easy class for developers to use when they need to generate barcode images from a string of data.
  • ImageStone
    An article on a library for image manipulation.
Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 11 of 11 (Total in Forum: 11) (Refresh)FirstPrevNext
GeneralThank you Pinmemberfuturejo8:05 27 Jul '09  
Generaltwo problems Pinmemberfrancisngl15:51 15 May '09  
GeneralTitle needs work. Pinmembermuzzdeni16:18 5 Mar '09  
GeneralChange the title Pinmemberkosmonafta22:23 9 Dec '08  
Generalcool PinmembertigerfCPRJ13:13 8 Dec '08  
GeneralDLL to be integrated? PinsupporterHegemon8:01 8 Dec '08  
GeneralNice code Pinmemberjohannesnestler6:51 5 Dec '08  
GeneralNice PinmemberDhimant Trivedi1:03 5 Dec '08  
GeneralThe article needs a better title PinmemberPIEBALDconsult6:08 3 Dec '08  
GeneralNice... PinmemberPaw Jershauge0:06 3 Dec '08  
Generale = mc^2 PinmemberTefik Becirovic23:58 2 Dec '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 2 Dec 2008
Editor: Smitha Vijayan
Copyright 2008 by Massimiliano Conte
Everything else Copyright © CodeProject, 1999-2009
Web10 | Advertise on the Code Project