-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathripple.py
More file actions
66 lines (47 loc) · 1.17 KB
/
ripple.py
File metadata and controls
66 lines (47 loc) · 1.17 KB
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
66
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
import math
r = 5
def clearscreen():
glClearColor(0.0, 0.0, 0.0, 1.0)
gluOrtho2D(-100, 100.0, -100.0, 100.0)
glPointSize(1.0)
def setpixel(x, y):
glBegin(GL_POINTS)
glVertex2f(x, y)
glEnd()
glFlush()
def update(value):
global r
glutPostRedisplay()
glutTimerFunc(int(1000/60), update, int(1))
r = r+5
def circle(xc, yc, r):
x, y = 0, r
while(x < y):
x = x+0.1
y = math.sqrt(r*r-x*x)
setpixel(x+xc, y+yc)
setpixel(-x+xc, y+yc)
setpixel(-x+xc, -y+yc)
setpixel(x+xc, -y+yc)
setpixel(y+xc, x+yc)
setpixel(-y+xc, x+yc)
setpixel(-y+xc, -x+yc)
setpixel(y+xc, -x+yc)
def display():
global r
circle(0, 0, r)
glutSwapBuffers()
def main():
glutInit()
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE)
glutCreateWindow("RIPPLE")
glutInitWindowSize(500, 500)
glutInitWindowPosition(200, 200)
glutDisplayFunc(display)
glutTimerFunc(0, update, 0)
clearscreen()
glutMainLoop()
main()