Click here to Skip to main content
5,787,682 members and growing! (16,785 online)
Email Password   helpLost your password?
Multimedia » General Graphics » Graphics     Intermediate License: The Code Project Open License (CPOL)

HowTo turn a good idea in a bad project

By Massimiliano Conte

a fast and furious - one step far from - screensaver application
C#, Windows, .NET, Visual Studio

Posted: 15 Oct 2008
Updated: 2 Dec 2008
Views: 4,271
Bookmarked: 20 times
Note: This is an unedited reader contribution
Announcements
Loading...



Search    
Advanced Search
Sitemap
15 votes for this Article.
Popularity: 5.60 Rating: 4.76 out of 5
0 votes, 0.0%
1
0 votes, 0.0%
2
0 votes, 0.0%
3
4 votes, 26.7%
4
11 votes, 73.3%
5
Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report This Article

Introduction

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

In this article there is no DirectX, OpenGL and something like it around.

Download Screenshot

Download Project

First Step

First of all, we will arrange the images around an ellipse. To obtain the - let's say - 10 points, having 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 top Y position to bottom. In an ellipse-arranged-thumb-rotator this works fine. Second: draw scaled from top Y position to bottom. Images on the top have to be smaller than 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 inverse.

Every time you draw an image, remember it's position. So, while 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).

It's all

Have fun. Remember, this is not the best way to do it, but it works! :)

bye

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


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

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 8 of 8 (Total in Forum: 8) (Refresh)FirstPrevNext
GeneralChange the titlememberkosmonafta22:23 9 Dec '08  
GeneralcoolmembertigerfCPRJ13:13 8 Dec '08  
GeneralDLL to be integrated?supporterHegemon8:01 8 Dec '08  
GeneralNice codememberjohannesnestler6:51 5 Dec '08  
GeneralNicememberDhimant Trivedi1:03 5 Dec '08  
GeneralThe article needs a better titlememberPIEBALDconsult6:08 3 Dec '08  
GeneralNice...memberPaw Jershauge0:06 3 Dec '08  
Generale = mc^2memberTefik 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:
Copyright 2008 by Massimiliano Conte
Everything else Copyright © CodeProject, 1999-2009
Web13 | Advertise on the Code Project