生命动画模拟_海龟画图版

"""生命动画模拟_海龟画图版"""

__author__ = "lixingqiu"
__date__ = "2018/11/29"

from turtle import Turtle,Screen
from random import randint

def draw_grid(rows,cols,cell_width,cell_height):
    """以海龟画图屏幕为中心点画格子"""
    t = Turtle(visible=False)
    t.screen.mode("standard")
     
    t.penup()
    table_width = cols * cell_width
    table_height = rows  * cell_height
    left =  - table_width // 2
    top = table_height // 2
    t.goto(left,top)

    t.down()
    for i in range(rows):
        t.fd(table_width)
        t.bk(table_width)
        t.sety(t.ycor() - cell_height)

    t.fd(table_width)
    t.left(90)
    t.fd(table_height)
    t.left(90)
    t.fd(cell_width)
     
    t.left(90)
    for i in range(cols-1):
        t.fd(table_height)
        t.bk(table_height)
        t.setx(t.xcor() - cell_width)

    t.left(90)
    t.hideturtle()

def generate_cors(rows,cols,grid_width,grid_height):
    """产生每个格子中心点坐标列表"""
    

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