-
Notifications
You must be signed in to change notification settings - Fork 0
/
circle.py
57 lines (40 loc) · 1.41 KB
/
circle.py
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
from OpenGL.GL import *
import numpy as np
from mid_point_lines import *
# PACMAN CIRCLE
def drawCurve(radius,pos_x, pos_y):
x = 0
y = radius
d=1-radius
trasnlate = np.array([[1, 0, pos_x],
[0, 1, pos_y],
[0, 0, 1]])
v1 = np.array([[0], # center of circle
[0],
[1]])
v11 = np.matmul(trasnlate, v1) # translate center of circle
while x < y:
glColor3f(1.0, .50, 0.0)
glPointSize(1)
glBegin(GL_POINTS)
#glVertex2f(v11[0][0] + y, v11[1][0] + x) #zone-0
glVertex2f(v11[0][0] + x, v11[1][0] + y) # zone-1
glVertex2f(v11[0][0] - x, v11[1][0] + y) # zone-2
glVertex2f(v11[0][0] - y, v11[1][0] + x) # zone-3
glVertex2f(v11[0][0] - y, v11[1][0] - x) # zone-4
glVertex2f(v11[0][0] - x, v11[1][0] - y) # zone-5
glVertex2f(v11[0][0] + x, v11[1][0] - y) # zone-6
#glVertex2f(v11[0][0] + y, v11[1][0] -x)#zone-7
glEnd()
if d < 0:
# choose east
d=d+2*x+3
x = x + 1
else:
# choosing south east
d=d+2*x-2*y+5
x = x + 1
y = y - 1
#drawing the pacman mouth
draw_midpoint_lines(v11[0][0] + x, v11[1][0] + y,v11[0][0], v11[1][0],'ok')
draw_midpoint_lines(v11[0][0] + x, v11[1][0] + -y,v11[0][0], v11[1][0],'ok')