当前位置:   article > 正文

​「Python绘图」绘制太极图

​「Python绘图」绘制太极图

python 绘制太极

一、预期结果

在这里插入图片描述

二、核心代码

import turtle

pen = turtle.Turtle()

print("开始绘制太极")

radius = 100
pen.color("black", "black")
pen.begin_fill()
pen.circle(radius/2, 180)
pen.circle(radius, 180)
pen.left(180)
pen.circle(-radius/2, 180)
pen.end_fill() 


pen.left(90)
pen.pu()
pen.fd(radius*0.35)
pen.right(90)
pen.pd()

print("绘制小圆")
pen.color("white", "white")
pen.begin_fill()
pen.circle(radius*0.15)
pen.end_fill() 


pen.left(90)
pen.up()
pen.backward(radius*0.7)
pen.down()
pen.left(90)

print("绘制小圆")
pen.color("black", "black")
pen.begin_fill()
pen.circle(radius*0.15)
pen.end_fill()

print("补大圆")
pen.right(90)
pen.pu()
pen.backward(radius*0.65)
pen.right(90)
pen.pd()
pen.circle(radius, 180)
print("绘制完成")
pen.ht()
turtle.done()

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/564843
推荐阅读
相关标签
  

闽ICP备14008679号