Advertisement
Guest User

Untitled

a guest
May 26th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.78 KB | None | 0 0
  1. # include "iGraphics.h"
  2. #include<math.h>
  3.  
  4. int x = 300, y = 300, r = 20;
  5. float pi = asin(1)*2;
  6. float theta = pi/2;
  7. float theta2 = pi/3;
  8. float theta3 = pi/6;
  9. /*
  10.     function iDraw() is called again and again by the system.
  11.  
  12.     */
  13. void secondkata()
  14. {
  15.     //iLine(250, 250, 250+190*cos(theta), 250+190*sin(theta));
  16.     theta = theta - 6*pi/180;
  17.     //iDraw;
  18. }
  19. void minutekata()
  20. {
  21.     theta2 = theta2 - (1/10)*pi/180;
  22. }
  23. void hourkata()
  24. {
  25.     theta3 = theta3 - (30/3600)*pi/180;
  26. }
  27. void iDraw() {
  28.     //place your drawing codes here
  29.     iClear();
  30.     iSetColor(192, 192, 192);
  31.     iFilledCircle(250, 250, 200);
  32.     //iFilledRectangle(10, 30, 20, 20);
  33.     iSetColor(20, 200, 0);
  34.     iText(40, 40, "Hi, I am kkpiGraphics");
  35.     iSetColor(64, 0, 0);
  36.     //secondkata();
  37.     iLine(250, 250, 250+190*cos(theta), 250+190*sin(theta));
  38.     iLine(250, 250, 250+170*cos(theta2), 250+170*sin(theta2));
  39.     iLine(250, 250, 250+150*cos(theta3), 250+150*sin(theta3));
  40.     iText(250+180, 250, "3", GLUT_BITMAP_TIMES_ROMAN_24);
  41.     iText(250+180*cos(pi/6), 250+180*sin(pi/6), "2", GLUT_BITMAP_TIMES_ROMAN_24);
  42.     iText(250+180*cos(pi/3), 250+180*sin(pi/3), "1", GLUT_BITMAP_TIMES_ROMAN_24);
  43.     iText(250+180*cos(pi/2), 250+180*sin(pi/2), "12", GLUT_BITMAP_TIMES_ROMAN_24);
  44.     iText(250+180*cos(pi/2+pi/6), 250+180*sin(pi/2+pi/6), "11", GLUT_BITMAP_TIMES_ROMAN_24);
  45.     iText(250+180*cos(pi/2+pi/3), 250+180*sin(pi/2+pi/3), "10", GLUT_BITMAP_TIMES_ROMAN_24);
  46.     iText(250+180*cos(pi/2+pi/2), 250+180*sin(pi/2+pi/2), "9", GLUT_BITMAP_TIMES_ROMAN_24);
  47.     iText(250+180*cos(pi+pi/6), 250+180*sin(pi+pi/6), "8", GLUT_BITMAP_TIMES_ROMAN_24);
  48.     iText(250+180*cos(pi+pi/3), 250+180*sin(pi+pi/3), "7", GLUT_BITMAP_TIMES_ROMAN_24);
  49.     iText(250+180*cos(pi+pi/2), 250+180*sin(pi+pi/2), "6", GLUT_BITMAP_TIMES_ROMAN_24);
  50.     iText(250+180*cos(pi+pi/2+pi/6), 250+180*sin(pi+pi/2+pi/6), "5", GLUT_BITMAP_TIMES_ROMAN_24);
  51.     iText(250+180*cos(pi+pi/2+pi/3), 250+180*sin(pi+pi/2+pi/3), "4", GLUT_BITMAP_TIMES_ROMAN_24);
  52. }
  53.  
  54. /*
  55.     function iMouseMove() is called when the user presses and drags the mouse.
  56.     (mx, my) is the position where the mouse pointer is.
  57.     */
  58. void iMouseMove(int mx, int my) {
  59.     printf("x = %d, y= %d\n",mx,my);
  60.     //place your codes here
  61. }
  62.  
  63. /*
  64.     function iMouse() is called when the user presses/releases the mouse.
  65.     (mx, my) is the position where the mouse pointer is.
  66.     */
  67. void iMouse(int button, int state, int mx, int my) {
  68.     if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) {
  69.         //place your codes here
  70.         //  printf("x = %d, y= %d\n",mx,my);
  71.         x += 10;
  72.         y += 10;
  73.     }
  74.     if (button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN) {
  75.         //place your codes here
  76.         x -= 10;
  77.         y -= 10;
  78.     }
  79. }
  80.  
  81. /*
  82.     function iKeyboard() is called whenever the user hits a key in keyboard.
  83.     key- holds the ASCII value of the key pressed.
  84.     */
  85. void iKeyboard(unsigned char key) {
  86.     if (key == 'q') {
  87.         exit(0);
  88.     }
  89.     //place your codes for other keys here
  90. }
  91.  
  92. /*
  93.     function iSpecialKeyboard() is called whenver user hits special keys like-
  94.     function keys, home, end, pg up, pg down, arraows etc. you have to use
  95.     appropriate constants to detect them. A list is:
  96.     GLUT_KEY_F1, GLUT_KEY_F2, GLUT_KEY_F3, GLUT_KEY_F4, GLUT_KEY_F5, GLUT_KEY_F6,
  97.     GLUT_KEY_F7, GLUT_KEY_F8, GLUT_KEY_F9, GLUT_KEY_F10, GLUT_KEY_F11, GLUT_KEY_F12,
  98.     GLUT_KEY_LEFT, GLUT_KEY_UP, GLUT_KEY_RIGHT, GLUT_KEY_DOWN, GLUT_KEY_PAGE UP,
  99.     GLUT_KEY_PAGE DOWN, GLUT_KEY_HOME, GLUT_KEY_END, GLUT_KEY_INSERT
  100.     */
  101. void iSpecialKeyboard(unsigned char key) {
  102.  
  103.     if (key == GLUT_KEY_END) {
  104.         exit(0);
  105.     }
  106.     //place your codes for other keys here
  107. }
  108.  
  109. void print(){
  110. printf("Kawshik BUET CSE'17    ");}
  111.  
  112. int main() {
  113.     //place your own initialization codes here.
  114.     iSetTimer(1000, secondkata);
  115.     iSetTimer(1000, minutekata);
  116.     iSetTimer(1000, hourkata);
  117.     iSetTimer(1000, print);
  118.     iInitialize(500, 500, "KAWSHIK KUMAR PAUL");
  119.  
  120.     return 0;
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement