随机路径生成器turtle简易版 random path maker

"""
   random_path.py
   这是一个用海龟画图制作的随机路径生成器,路径大概是从左到右.random_path会返回路径节点坐标点列表.
"""
from random import randint
from turtle import Turtle,Screen
def random_path(color,width):
    """color:颜色,width:宽度"""
    cors = []
    p = Turtle(visible=False)
    # 下面两句是重画背景
    p.width(10000)
    p.dot(10000,"cyan")
    p.penup()
    screen = p.getscreen()   
    p.sw = screen.window_width()
    p.sh = screen.window_height()   
    p.goto(-p.sw//2,0)
    cors.append(p.position())
    p.pensize(width)
    p.color(color)
    p.pendown()

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