试读部分
绘图之前先要安装turtle模块: python 2: pip install turtle
python 3: pip3 install turtle
绘图思路: 首先绘制出外正方形和内线,然后使用dot绘制出九个跑位的点,记录每个点的x和y轴,写入死循环和if判断条件判断是否为中圆点并闪烁。 效果图展示: 效果图代码: #woshinsy
import turtle
import time
import random
turtle.title("woshinsy python homework")
# 窗口大小
turtle.bgcolor("#367847")
# 大圈
def bcir():
turtle.dot(65,"yellow")
# 小圈
def cir():
turtle.dot(45, "white")
# 横纵坐标
def tp(x,y):
turtle.penup()
turtle.goto(x,y)
turtle.pendown()
# 球场设置
def square():
turtle.color("white")
for i in range(4):
turtle.pensize(10)
turtle.forward(500)
turtle.left(90)
#隐藏箭头
turtle.speed(9)
turtle.hideturtle()
tp(-250,-250)
square()
tp(-250,125)
turtle.forward(500)
tp(0,120)
turtle.left(-90)
turtle.forward(370)
tp(0,0)
bcir()
# 上1
tp(-250,250)
cir()
# 上2……
本文为 VIP 文章,已展示部分内容,开通 VIP 后查看全文
觉得这篇文章有帮助?
点个赞,或赞赏支持作者持续创作