-
Notifications
You must be signed in to change notification settings - Fork 0
/
midCircle.py
65 lines (53 loc) · 1.12 KB
/
midCircle.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
58
59
60
61
62
63
64
65
print("Welcome in python")
from graphics import *
print("Enter the Radius of a circle : ")
r = int(input())
p = 1.25 - r
# center of circle:
xn = yn = 150
x1 = 0
y1 = r
win = GraphWin("circle-draw-by-mid-point-algo",500, 500)
plt = Point(xn+x1,yn+y1)
plt.draw(win)
plt = Point(xn+y1,yn+x1)
plt.draw(win)
plt = Point(xn+x1,yn-y1)
plt.draw(win)
plt = Point(xn+y1,yn-x1)
plt.draw(win)
plt = Point(xn-x1,yn-y1) #hh
plt.draw(win)
plt = Point(xn-x1,yn+y1)
plt.draw(win)
plt = Point(xn-y1,yn+x1)
plt.draw(win)
plt = Point(xn-y1,yn-x1)
plt.draw(win)
while x1 < y1 :
plt = Point(xn+x1,yn+y1)
plt.draw(win)
plt = Point(xn+y1,yn+x1)
plt.draw(win)
plt = Point(xn+x1,yn-y1)
plt.draw(win)
plt = Point(xn+y1,yn-x1)
plt.draw(win)
plt = Point(xn-x1,yn-y1)
plt.draw(win)
plt = Point(xn-x1,yn+y1)
plt.draw(win)
plt = Point(xn-y1,yn+x1)
plt.draw(win)
plt = Point(xn-y1,yn-x1)
plt.draw(win)
if p < 0 :
x1 = x1 + 1
y1 = y1
p = p + 2*x1 + 1
else :
x1 = x1 + 1
y1 = y1 - 1
p = p + 2*(x1-y1) + 1
# Enter to exit:
x = int(input())