Python海龟画图画板2020617版

李兴球Python海龟画图的画板

李兴球Python海龟画图的画板

"""
   Python海龟画图画版2020617版
"""
import turtle

screen = turtle.getscreen()
screen.setup(480,360)
screen.bgcolor('black')
screen.delay(0)

turtle.color('magenta')
turtle.speed(0)
turtle.penup()
turtle.ht()

last_pos = None

def begindraw(event):
    global last_pos
    x = event.x - 240                   # 转换成海龟坐标系中的x坐标
    y = 180 - event.y                   # 转换成海龟坐标系中的y坐标
    if last_pos is not None:
        turtle.goto(last_pos)
        turtle.pendown()
        turtle.goto(x,y)

def enddraw(event):
    turtle.penup()
    last_pos = None
    
pass                                  # 这里省略了若干代码......
screen.mainloop()

需要所有源代码,请

成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)

关于李兴球

李兴球的博客是Python创意编程原创博客
此条目发表在python, turtle分类目录,贴了, 标签。将固定链接加入收藏夹。

发表回复