943,788 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 3202
  • C++ RSS
Apr 24th, 2009
0

graphics project about drawing circle in C++

Expand Post »
Hi all,
I have to make a graphics project about drawing a circle like:
1/Draw the circle on the screen with yellow pen color and dark blue background. (Note: yellow
color: 0xFFFF00, dark blue color: 0x191970).
2/ Rotate the circle counterclockwise around the center I with the speed 10 degree per second, the
rotating will stop when user press ‘q’.
but I just did the first requirement.
Here is my work, can you help me with the second requirement!
Attached Files
File Type: zip prac1.zip (150.6 KB, 594 views)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
thebluestar is offline Offline
55 posts
since Apr 2009
Apr 24th, 2009
0

Re: graphics project about drawing circle in C++

Here is my work, can you help me with the second requirement!
Sure we can help you, but that's such a vague question ...
Where are you having problems with ?
Reputation Points: 2125
Solved Threads: 243
Postaholic
tux4life is offline Offline
2,105 posts
since Feb 2009
Apr 24th, 2009
0

Re: graphics project about drawing circle in C++

Hmmm seems like you need to bust out the math book. I honestly dont remember the math functions in CMath, but you should probably look it up. I also don't know how the library you are using supports key entry for stopping, so I'll just say its called GetKey() and returns a character. Also I don't know anything about your circle class, but I will assume it accepts 2 coordinates and a radius.

C++ Syntax (Toggle Plain Text)
  1. double fX = 0;
  2. double fY = 0;
  3. double fAngle = 0; //in radians
  4. const int ciRadius = 10;
  5. const double cfPi = 3.14159;
  6. const int ciAngularVelocity = 10; //in degrees
  7. const int ciAmplitude = 100;
  8. while (GetKey() != 'q')
  9. {
  10. fX = SIN(fAngle) * ciAmplitude;
  11. fY = COS(fAngle) * ciAmplitude;
  12. DrawCircle(iX, iY, ciRadius)
  13. sleep(1000); //pause for a second
  14. fAngle += (ciAngularVelocity * (cfPi / 180.0f));
  15. }

Something like that should do the trick. Probably not the exact code you need for your specific application, but it should give you a damn good idea.
Reputation Points: 352
Solved Threads: 109
Master Poster
skatamatic is offline Offline
775 posts
since Nov 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Using a sentinal controlled while loop
Next Thread in C++ Forum Timeline: question





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC