| | |
graphics project about drawing circle in C++
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2009
Posts: 28
Reputation:
Solved Threads: 0
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!
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!
•
•
Join Date: Nov 2007
Posts: 390
Reputation:
Solved Threads: 39
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.
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.
C++ Syntax (Toggle Plain Text)
double fX = 0; double fY = 0; double fAngle = 0; //in radians const int ciRadius = 10; const double cfPi = 3.14159; const int ciAngularVelocity = 10; //in degrees const int ciAmplitude = 100; while (GetKey() != 'q') { fX = SIN(fAngle) * ciAmplitude; fY = COS(fAngle) * ciAmplitude; DrawCircle(iX, iY, ciRadius) sleep(1000); //pause for a second fAngle += (ciAngularVelocity * (cfPi / 180.0f)); }
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.
![]() |
Similar Threads
Other Threads in the C++ Forum
- Previous Thread: Using a sentinal controlled while loop
- Next Thread: question
| Thread Tools | Search this Thread |
api array based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






