-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSmily.py
More file actions
66 lines (53 loc) · 2.01 KB
/
Copy pathSmily.py
File metadata and controls
66 lines (53 loc) · 2.01 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 graphics import *
win = GraphWin("Midpoint Circle", 600, 600)
def midPointCircleDraw(x_centre, y_centre, r,flag):
x = r
y = 0
print("(", x + x_centre, ", ", y + y_centre, ")")
if r > 0:
print("({xval}, {yval})".format(xval=x+x_centre, yval=y+y_centre))
print("(", y + x_centre, ", ", x + y_centre, ")")
print("(", -y + x_centre, ", ", x + y_centre, ")")
P = 1 - r
while x > y:
y += 1
if P <= 0:
P = P + 2 * y + 1
else:
x -= 1
P = P + 2 * y - 2 * x + 1
if x < y:
break
print("(", x + x_centre, ", ", y + y_centre, ")")
print("(", -x + x_centre, ", ", y + y_centre, ")")
print("(", x + x_centre, ", ", -y + y_centre, ")")
print("(", -x + x_centre, ", ", -y + y_centre, ")")
if flag=='c':
plotPoints(x + x_centre, y + y_centre)
plotPoints(-x + x_centre, y + y_centre)
plotPoints(x + x_centre, -y + y_centre)
plotPoints(-x + x_centre, -y + y_centre)
if x != y :
print("(", y + x_centre, ", ", x + y_centre, ")")
print("(", -y + x_centre, ", ", x + y_centre, ")")
print("(", y + x_centre, ", ", -x + y_centre, ")")
print("(", -y + x_centre, ", ", -x + y_centre, ")")
plotPoints(y + x_centre, x + y_centre)
plotPoints(-y + x_centre, x + y_centre)
if flag == 'c':
plotPoints(y + x_centre, -x + y_centre)
plotPoints(-y + x_centre, -x + y_centre)
def getInput():
x,y,r = [int(x) for x in input("Enter the coordinates and the radius of the centre: ").split()]
return x, y, r
def plotPoints(x, y):
point = Point(x, y)
point.draw(win)
if __name__ == '__main__':
#xc, yc, rc = getInput()
midPointCircleDraw(300, 300, 300,'c')
midPointCircleDraw(150, 200, 50,'c')
midPointCircleDraw(450, 200, 50,'c')
midPointCircleDraw(300, 350, 150, 's')
win.getMouse()
win.close()