Python 文库

turtle - turtledemo - yinyang [太

2021-02-27  本文已影响0人  巭牛猫
【 太 极 图 】
#!/usr/bin/env python3
"""       turtle-example-suite:

            tdemo_yinyang.py

Another drawing suitable as a beginner's
programming example.

The small circles are drawn by the circle
command.

"""

from turtle import *

def yin(radius, color1, color2):
    width(3)
    color("black", color1)
    begin_fill()
    circle(radius/2., 180)
    circle(radius, 180)
    left(180)
    circle(-radius/2., 180)
    end_fill()
    left(90)
    up()
    forward(radius*0.35)
    right(90)
    down()
    color(color1, color2)
    begin_fill()
    circle(radius*0.15)
    end_fill()
    left(90)
    up()
    backward(radius*0.35)
    down()
    left(90)

def main():
    reset()
    yin(200, "black", "white")
    yin(200, "white", "black")
    ht()
    return "Done!"

if __name__ == '__main__':
    main()
    mainloop()

内容来源:官方文库
牛猫名言:最好的资料就是官方文档


本文链接:https://www.jianshu.com/p/aab952264db7
转载请注明,谢谢!
编辑:牛猫大侠


上一篇下一篇

猜你喜欢

热点阅读