Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # include "iGraphics.h"
- #include <time.h>
- int x = 00, y = 00, r = 20;
- int hour, mini, sec;
- /*
- function iDraw() is called again and again by the system.
- */
- int col[7];
- void iDraw() {
- //place your drawing codes here
- iClear();
- iSetColor(col[6], 0, 0);
- iFilledRectangle(40,40, 50, 10); ///7
- iSetColor(col[4], 0, 0);
- iFilledRectangle(0, 110,10, 50); ///5
- iSetColor(col[5], 0, 0);
- iFilledRectangle(90 + 60, 110,10, 50); ///6
- iSetColor(col[3], 0, 0);
- iFilledRectangle(100,160, 50, 10); ///4
- iSetColor(col[1], 0, 0);
- iFilledRectangle(90, 110 + 60,10, 50); ///2
- iSetColor(col[2], 0, 0);
- iFilledRectangle(40, 10,10, 50); ///3
- iSetColor(col[0], 0, 0);
- iFilledRectangle(100,220, 50, 10); ///1
- //iFilledRectangle(10, 30, 20, 20);
- iSetColor(20, 200, 0);
- iText(40, 40, "Hi, I am iGraphics");
- }
- /*
- 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 fun()
- {
- int i = 1;
- ///For 1
- if(i == 1)
- {
- col[2] = 255;
- col[5] = 255;
- for(int i = 0; i < 7; i++)
- {
- if(i == 2) continue;
- if(i == 5) continue;
- col[i] = 0;
- }
- }
- if(i == 2)
- {
- col[0] = 255;
- col[2] = 255;
- col[3] = 255;
- col[4] = 255;
- col[6] = 255;
- col[1] = 0;
- col[5] = 0;
- }
- i = i + 1;
- if(i == 3) i = 1;
- }
- void change_sec()
- {
- }
- void change_min()
- {
- mini = (mini + 1);
- }
- void change_hour()
- {
- }
- int main()
- {
- sec = 45;
- hour = 12;
- mini = 31;
- time_t current;
- tm* pt;
- time(¤t);
- pt = gmtime(¤t);
- hour = (pt -> tm_hour + 6)%12;
- mini = (pt -> tm_min);
- sec=(pt -> tm_sec) - 2;
- iSetTimer(1000, change_sec );
- iSetTimer(60000, change_min);
- iSetTimer(60000*60, change_hour);
- iInitialize(400, 400, "clock");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement