minHand.shape(“minHand”)
houHand = turtle.Turtle()
houHand.shape(“houHand”)
for hand in secHand, minHand, houHand:
hand.shapesize(1, 1, 3)
hand.speed(0)
建立输出文字Turtle
printer = turtle.Turtle()
隐藏画笔的turtle形状
printer.hideturtle()
printer.penup()
绘制表盘
def setupClock(radius):
建立表的外框
turtle.reset()
turtle.pensize(7)
for i in range(60):
向前移动半径值
skip(radius)
if i % 5 == 0:
画长刻度线
turtle.forward(20)
回到中心点
skip(-radius - 20)
移动到刻度线终点
skip(radius + 20)
下面是写表盘刻度值,为了不与划线重叠,所以对于特殊位置做了处理
if i == 0:
turtle.write(int(12), align=“center”, font=(“Courier”, 14, “bold”))
elif i == 30:
skip(25)
turtle.write(int(i / 5), align=“center”, font=(“Courier”, 14, “bold”))
skip(-25)
elif (i == 25 or i == 35):
skip(20)
turtle.write(int(i / 5), align=“center”, font=(“Courier”, 14, “bold”))
skip(-20)
else:
turtle.write(int(i / 5), align=“center”, font=(“Courier”, 14, “bold”))