Advertisement
Afsara

Untitled

May 13th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1. # include "iGraphics.h"
  2. #include <time.h>
  3.  
  4.  
  5. int x = 00, y = 00, r = 20;
  6. int hour, mini, sec;
  7.  
  8. /*
  9. function iDraw() is called again and again by the system.
  10.  
  11. */
  12.  
  13. int col[7];
  14. void iDraw() {
  15. //place your drawing codes here
  16. iClear();
  17. iSetColor(col[6], 0, 0);
  18. iFilledRectangle(40,40, 50, 10); ///7
  19.  
  20. iSetColor(col[4], 0, 0);
  21. iFilledRectangle(0, 110,10, 50); ///5
  22.  
  23. iSetColor(col[5], 0, 0);
  24. iFilledRectangle(90 + 60, 110,10, 50); ///6
  25.  
  26. iSetColor(col[3], 0, 0);
  27. iFilledRectangle(100,160, 50, 10); ///4
  28.  
  29. iSetColor(col[1], 0, 0);
  30. iFilledRectangle(90, 110 + 60,10, 50); ///2
  31.  
  32. iSetColor(col[2], 0, 0);
  33. iFilledRectangle(40, 10,10, 50); ///3
  34.  
  35. iSetColor(col[0], 0, 0);
  36. iFilledRectangle(100,220, 50, 10); ///1
  37. //iFilledRectangle(10, 30, 20, 20);
  38. iSetColor(20, 200, 0);
  39. iText(40, 40, "Hi, I am iGraphics");
  40. }
  41.  
  42. /*
  43. function iMouseMove() is called when the user presses and drags the mouse.
  44. (mx, my) is the position where the mouse pointer is.
  45. */
  46. void iMouseMove(int mx, int my) {
  47. printf("x = %d, y= %d\n",mx,my);
  48. //place your codes here
  49. }
  50.  
  51. /*
  52. function iMouse() is called when the user presses/releases the mouse.
  53. (mx, my) is the position where the mouse pointer is.
  54. */
  55. void iMouse(int button, int state, int mx, int my) {
  56. if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) {
  57. //place your codes here
  58. // printf("x = %d, y= %d\n",mx,my);
  59. x += 10;
  60. y += 10;
  61. }
  62. if (button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN) {
  63. //place your codes here
  64. x -= 10;
  65. y -= 10;
  66. }
  67. }
  68.  
  69. /*
  70. function iKeyboard() is called whenever the user hits a key in keyboard.
  71. key- holds the ASCII value of the key pressed.
  72. */
  73. void iKeyboard(unsigned char key) {
  74. if (key == 'q') {
  75. exit(0);
  76. }
  77. //place your codes for other keys here
  78. }
  79.  
  80. /*
  81. function iSpecialKeyboard() is called whenver user hits special keys like-
  82. function keys, home, end, pg up, pg down, arraows etc. you have to use
  83. appropriate constants to detect them. A list is:
  84. GLUT_KEY_F1, GLUT_KEY_F2, GLUT_KEY_F3, GLUT_KEY_F4, GLUT_KEY_F5, GLUT_KEY_F6,
  85. GLUT_KEY_F7, GLUT_KEY_F8, GLUT_KEY_F9, GLUT_KEY_F10, GLUT_KEY_F11, GLUT_KEY_F12,
  86. GLUT_KEY_LEFT, GLUT_KEY_UP, GLUT_KEY_RIGHT, GLUT_KEY_DOWN, GLUT_KEY_PAGE UP,
  87. GLUT_KEY_PAGE DOWN, GLUT_KEY_HOME, GLUT_KEY_END, GLUT_KEY_INSERT
  88. */
  89. void iSpecialKeyboard(unsigned char key) {
  90.  
  91. if (key == GLUT_KEY_END) {
  92. exit(0);
  93. }
  94. //place your codes for other keys here
  95. }
  96.  
  97. void fun()
  98. {
  99. int i = 1;
  100. ///For 1
  101. if(i == 1)
  102. {
  103. col[2] = 255;
  104. col[5] = 255;
  105. for(int i = 0; i < 7; i++)
  106. {
  107. if(i == 2) continue;
  108. if(i == 5) continue;
  109. col[i] = 0;
  110. }
  111. }
  112.  
  113. if(i == 2)
  114. {
  115. col[0] = 255;
  116. col[2] = 255;
  117. col[3] = 255;
  118. col[4] = 255;
  119. col[6] = 255;
  120.  
  121. col[1] = 0;
  122. col[5] = 0;
  123. }
  124.  
  125. i = i + 1;
  126. if(i == 3) i = 1;
  127.  
  128.  
  129. }
  130.  
  131.  
  132. void change_sec()
  133. {
  134.  
  135.  
  136. }
  137.  
  138. void change_min()
  139. {
  140. mini = (mini + 1);
  141.  
  142. }
  143.  
  144. void change_hour()
  145. {
  146.  
  147. }
  148.  
  149.  
  150. int main()
  151. {
  152. sec = 45;
  153. hour = 12;
  154. mini = 31;
  155.  
  156. time_t current;
  157. tm* pt;
  158. time(&current);
  159. pt = gmtime(&current);
  160. hour = (pt -> tm_hour + 6)%12;
  161. mini = (pt -> tm_min);
  162. sec=(pt -> tm_sec) - 2;
  163.  
  164. iSetTimer(1000, change_sec );
  165. iSetTimer(60000, change_min);
  166. iSetTimer(60000*60, change_hour);
  167. iInitialize(400, 400, "clock");
  168. return 0;
  169. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement