1. 程式人生 > >Python 繪制圍棋棋盤

Python 繪制圍棋棋盤

class end image nbsp idt img 格子 分享 goto

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)


pen.right(90)
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()

技術分享圖片

Python 繪制圍棋棋盤