-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpython turtle-clock.py
123 lines (121 loc) · 2.68 KB
/
python turtle-clock.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#I try to write my code only using turtle functions.The main purpose of this project is creating clock only by using turtle graphics.(“i try to create my own turtle analog clock by using only turtle graphics”)
import turtle
t=turtle.Screen()
t.title("clock design")
t.setup(width=410,height=410)
#t.bgpic('img.gif')
t.bgcolor('black')
sec=turtle.Turtle()
name=turtle.Turtle()
min=turtle.Turtle()
hour=turtle.Turtle()
text=turtle.Turtle()
red=turtle.Turtle()
green=turtle.Turtle()
yellow=turtle.Turtle()
hour.hideturtle()
min.hideturtle()
sec.hideturtle()
text.hideturtle()
name.hideturtle()
min.speed(80)
text.speed(1000)
red.speed(10000)
yellow.speed(10000)
green.speed(10000)
min.pencolor('black')
hour.pencolor("red")
text.pencolor("orange")
min.pencolor("yellow")
sec.pencolor('green')
yellow.shape('circle')
red.shape('circle')
green.shape('circle')
yellow.fillcolor('yellow')
red.fillcolor('red')
green.fillcolor('green')
def name_writer():
type=('courier',14,'bold')
name.left(90)
name.penup()
name.forward(170)
name.pendown()
name.color('white')
name.write("TCLOCK",font=type,align='center')
def text_writer(x=0,y=0,r=110):
text.left(90)
a=30
numlist = ['፩', '፪', '፫', '፬', '፭', '፮', '፯', '፰', '፱', '፲', '፲፩', '፲፪']
for i in numlist:
type=('courier',12,'bold')
text.color('black')
text.penup()
text.right(a)
text.forward(87)
text.pendown()
text.write(i,font=type)
text.penup()
text.backward(87)
def draw_circle(x=0,y=0,radius=110):
green.pencolor('green')
green.pensize(2.5)
green.penup()
green.goto(x,y-radius)
green.pendown()
green.circle(radius,240)
yellow.pencolor('yellow')
yellow.pensize(5)
yellow.penup()
yellow.home()
yellow.goto(x,y-radius)
yellow.pendown()
yellow.circle(radius+5,240)
red.pencolor('red')
red.pensize(3.5)
red.penup()
red.home()
red.goto(x,y-radius)
red.pendown()
red.circle(radius+10,240)
sec.left(90)
hour.right(60)
def clock():
min.dot(15)
i=0
angle=30
while i<=12:
j=0
ang=6
while j<=60:
min.clear()
min.dot(15)
min.right(ang)
min.forward(60)
min.backward(60)
k=0
angl=6
while k<=60:
sec.speed(1.26)
sec.hideturtle()
sec.forward(75)
sec.speed(0.2)
sec.showturtle()
sec.speed(0.5)
sec.hideturtle()
sec.speed(10)
sec.backward(75)
sec.right(angl)
sec.speed(80)
sec.clear()
k=k+1
hour.forward(40)
hour.backward(40)
name_writer()
text_writer()
draw_circle()
min.left(90)
sec.pensize(2)
hour.pensize(7)
min.pensize(3)
hour.forward(45)
clock()