Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # include "iGraphics.h"
- #include<math.h>
- int x = 300, y = 300, r = 20;
- float pi = asin(1)*2;
- float theta = pi/2;
- float theta2 = pi/3;
- float theta3 = pi/6;
- /*
- function iDraw() is called again and again by the system.
- */
- void secondkata()
- {
- //iLine(250, 250, 250+190*cos(theta), 250+190*sin(theta));
- theta = theta - 6*pi/180;
- //iDraw;
- }
- void minutekata()
- {
- theta2 = theta2 - (1/10)*pi/180;
- }
- void hourkata()
- {
- theta3 = theta3 - (30/3600)*pi/180;
- }
- void iDraw() {
- //place your drawing codes here
- iClear();
- iSetColor(192, 192, 192);
- iFilledCircle(250, 250, 200);
- //iFilledRectangle(10, 30, 20, 20);
- iSetColor(20, 200, 0);
- iText(40, 40, "Hi, I am kkpiGraphics");
- iSetColor(64, 0, 0);
- //secondkata();
- iLine(250, 250, 250+190*cos(theta), 250+190*sin(theta));
- iLine(250, 250, 250+170*cos(theta2), 250+170*sin(theta2));
- iLine(250, 250, 250+150*cos(theta3), 250+150*sin(theta3));
- iText(250+180, 250, "3", GLUT_BITMAP_TIMES_ROMAN_24);
- iText(250+180*cos(pi/6), 250+180*sin(pi/6), "2", GLUT_BITMAP_TIMES_ROMAN_24);
- iText(250+180*cos(pi/3), 250+180*sin(pi/3), "1", GLUT_BITMAP_TIMES_ROMAN_24);
- iText(250+180*cos(pi/2), 250+180*sin(pi/2), "12", GLUT_BITMAP_TIMES_ROMAN_24);
- iText(250+180*cos(pi/2+pi/6), 250+180*sin(pi/2+pi/6), "11", GLUT_BITMAP_TIMES_ROMAN_24);
- iText(250+180*cos(pi/2+pi/3), 250+180*sin(pi/2+pi/3), "10", GLUT_BITMAP_TIMES_ROMAN_24);
- iText(250+180*cos(pi/2+pi/2), 250+180*sin(pi/2+pi/2), "9", GLUT_BITMAP_TIMES_ROMAN_24);
- iText(250+180*cos(pi+pi/6), 250+180*sin(pi+pi/6), "8", GLUT_BITMAP_TIMES_ROMAN_24);
- iText(250+180*cos(pi+pi/3), 250+180*sin(pi+pi/3), "7", GLUT_BITMAP_TIMES_ROMAN_24);
- iText(250+180*cos(pi+pi/2), 250+180*sin(pi+pi/2), "6", GLUT_BITMAP_TIMES_ROMAN_24);
- iText(250+180*cos(pi+pi/2+pi/6), 250+180*sin(pi+pi/2+pi/6), "5", GLUT_BITMAP_TIMES_ROMAN_24);
- iText(250+180*cos(pi+pi/2+pi/3), 250+180*sin(pi+pi/2+pi/3), "4", GLUT_BITMAP_TIMES_ROMAN_24);
- }
- /*
- function iMouseMove() is called when the user presses and drags the mouse.
- (mx, my) is the position where the mouse pointer is.
- */
- void iMouseMove(int mx, int my) {
- printf("x = %d, y= %d\n",mx,my);
- //place your codes here
- }
- /*
- function iMouse() is called when the user presses/releases the mouse.
- (mx, my) is the position where the mouse pointer is.
- */
- void iMouse(int button, int state, int mx, int my) {
- if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) {
- //place your codes here
- // printf("x = %d, y= %d\n",mx,my);
- x += 10;
- y += 10;
- }
- if (button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN) {
- //place your codes here
- x -= 10;
- y -= 10;
- }
- }
- /*
- function iKeyboard() is called whenever the user hits a key in keyboard.
- key- holds the ASCII value of the key pressed.
- */
- void iKeyboard(unsigned char key) {
- if (key == 'q') {
- exit(0);
- }
- //place your codes for other keys here
- }
- /*
- function iSpecialKeyboard() is called whenver user hits special keys like-
- function keys, home, end, pg up, pg down, arraows etc. you have to use
- appropriate constants to detect them. A list is:
- GLUT_KEY_F1, GLUT_KEY_F2, GLUT_KEY_F3, GLUT_KEY_F4, GLUT_KEY_F5, GLUT_KEY_F6,
- GLUT_KEY_F7, GLUT_KEY_F8, GLUT_KEY_F9, GLUT_KEY_F10, GLUT_KEY_F11, GLUT_KEY_F12,
- GLUT_KEY_LEFT, GLUT_KEY_UP, GLUT_KEY_RIGHT, GLUT_KEY_DOWN, GLUT_KEY_PAGE UP,
- GLUT_KEY_PAGE DOWN, GLUT_KEY_HOME, GLUT_KEY_END, GLUT_KEY_INSERT
- */
- void iSpecialKeyboard(unsigned char key) {
- if (key == GLUT_KEY_END) {
- exit(0);
- }
- //place your codes for other keys here
- }
- void print(){
- printf("Kawshik BUET CSE'17 ");}
- int main() {
- //place your own initialization codes here.
- iSetTimer(1000, secondkata);
- iSetTimer(1000, minutekata);
- iSetTimer(1000, hourkata);
- iSetTimer(1000, print);
- iInitialize(500, 500, "KAWSHIK KUMAR PAUL");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement