使用python turtle画一个简易的太极图

本篇文章为大家展示了使用python turtle画一个简易的太极图,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

具体效果:      

使用python turtle画一个简易的太极图代码如下:

import turtle

t=turtle.Turtle()

t.penup()

t.goto(0,-50)#设置起始坐标

t.pendown()

t.begin_fill()

t.fillcolor('black')

t.circle(150,extent=180)

t.circle(75,extent=180)#半径正负代表逆时针和顺时针画

t.circle(-75,extent=180)

t.end_fill()

t.circle(-150,extent=180)

t.penup()

t.goto(0,160)

t.pendown()

t.begin_fill()

t.fillcolor("white")

t.circle(30,extent=360)

t.end_fill()

t.penup()

t.goto(0,0)

t.pendown()

t.begin_fill()

t.fillcolor("black")

t.circle(30,extent=360)

t.end_fill()

turtle.done()

上述内容就是使用python turtle画一个简易的太极图,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注行业资讯频道。