python模拟水波纹,单击会画同心圆,用来模拟ripple

''' 本程序模拟水波纹,单击会画同心圆,用来模拟ripple'''

from turtle import Turtle,Screen     # 导入海龟类
from random import randint
 
def draw(x,y):     
    radius = 10
    t = Turtle(visible = False)
    t.color(29,153,231)
    t.pensize(4)
    t.penup()
    t.speed(0)
    def ripple():
        nonlocal radius 
        t.goto(x,y)
        t.fd(radius)
        t.left(90)        
        t.pendown()
        t.circle(radius)
        t.penup()
        radius = radius + 10
        if radius> 500:
            return
        else:
            t.screen.ontimer(ripple,50)
    ripple()
    

You must log in to read the rest of this article. Please log in or register as a user.