600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > pythonturtle八卦_使用turtle绘制太极八卦图

pythonturtle八卦_使用turtle绘制太极八卦图

时间:2019-03-24 05:01:32

相关推荐

pythonturtle八卦_使用turtle绘制太极八卦图

话不多说,直接看效果

太极八卦图.png

下面是源码

# coding: utf-8

import turtle as t

colors = ['white', 'black']

# 设置画笔宽度

t.pensize(4)

# 移动时不绘制图形,提起笔,用于另起一个地方绘制时用

t.penup()

# 将画笔移动到坐标为x,y的位置

t.goto(0, 200)

# 移动时绘制图形,缺省时也为绘制

t.pendown()

# 同时设置pencolor=color1, fillcolor=color2

t.color(colors[1],colors[1])

# 准备开始填充图形

t.begin_fill()

# 画圆,半径为正(负),表示圆心在画笔的左边(右边)画圆

t.circle(-50,-180)

t.circle(50,-180)

t.circle(100,180)

# 填充完成

t.end_fill()

t.circle(100,180)

t.penup()

t.goto(0, 140)

t.pendown()

t.color(colors[0],colors[0])

t.begin_fill()

t.circle(10)

t.end_fill()

t.penup()

t.goto(0, 40)

t.pendown()

t.color(colors[1],colors[1])

t.begin_fill()

t.circle(10)

t.end_fill()

t.penup()

t.goto(-50, -100)

t.write("这是一个八卦", font=('Arial', 20, 'normal'))

# 启动事件循环 -调用Tkinter的mainloop函数。

#

# 必须是乌龟图形程序中的最后一个语句。

t.done()

欢迎对python感兴趣的同学批评指正,共同交流学习。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。