Python 绘制棋盘

import turtle

pen = turtle.Pen()
pen.speed(10)

width = 30  # 格子宽度
count = 18  # 横向纵向格子数

o = width * count / 2  # 开始绘制原点

for i in range(count + 1):
    pen.penup()
    pen.goto(-o, o - i * width)
    pen.pendown()
    pen.goto(o, o - i * width)

for i in range(count + 1):
    pen.penup()
    pen.goto(-o + i * width, o)
    pen.pendown()
    pen.goto(-o + i * width, -o)

pen.hideturtle()
turtle.done()

 

posted @ 2018-11-06 12:14  寒爵  阅读(4647)  评论(0编辑  收藏  举报