-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathonClickCircleAnim.c
67 lines (61 loc) · 1.35 KB
/
onClickCircleAnim.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include<stdio.h>
#include<GL/glut.h>
#include <unistd.h>
#include<math.h>
#define PI 3.1415926535897932384626433832795
double x,y,j,i;
// function to initialize
void myInit (void)
{
// making background color black as first
// 3 arguments all are 0.0
glClearColor(0.0, 0.0, 0.0, 1.0);
}
void show(double X, double Y)
{
for(j=0.0; j<=0.5; j+=0.0001)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(j+j, 1.0-j-j, j+j+j);
glBegin(GL_LINE_LOOP);
for (i = 0;i < 2*PI;i +=2*PI/ 30 )
{
glVertex2f( X + j * cos(i), Y + j * sin(i));
}
glEnd();
glFlush();
}
for(j=0.5; j>=0.0; j-=0.0001)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(j+j, 1.0-j-j, j+j+j);
glBegin(GL_LINE_LOOP);
for (i = 0;i < 2*PI;i +=2*PI/ 30 )
{
glVertex2f( X + j * cos(i), Y + j * sin(i));
}
glEnd();
glFlush();
}
}
void mouseClick(int button, int state, int X, int Y)
{
if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
{
show((X-250)*(2.0/500),(250-Y)*(2.0/500));
glClear(GL_COLOR_BUFFER_BIT);
}
}
int main (int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
// giving window size in X- and Y- direction
glutInitWindowSize(500, 500);
// Giving name to window
glutCreateWindow("Cicle Animation");
myInit();
//glutDisplayFunc(display);
glutMouseFunc(mouseClick);
glutMainLoop();
}