基于turtle库用python画太极图案

Python-turtle库想必就不用说了,不会安装请看:pip安装

这里使用turtle库进行图案绘画,简单易学,新手必备采集失败,请手动处理

 

好了废话不多说,直接上代码~~

import turtle
def yin(radius, color1, color2):
t.width(3)
t.color("black", color1)
t.begin_fill()
t.circle(radius/2, 180)
t.circle(radius, 180)
t.left(180)
t.circle(-radius/2, 180)
t.end_fill()
t.left(90)
t.up()
t.fd(radius * 0.35)
t.right(90)
t.down()
t.color(color1, color2)
t.begin_fill()
t.circle(radius * 0.15)
t.end_fill()
t.left(90)
t.up()
t.bk(radius * 0.35)
t.down()
t.left(90)
def main():
t.reset()
yin(200, 'black', 'white')
yin(200, 'white', 'black')
if __name__ == "__main__":
t = turtle.Turtle()
main()
print("hello")
turtle.mainloop()

更多精彩内容

点赞

发表回复

电子邮件地址不会被公开。必填项已用 * 标注