猫史档案馆


【Python作品分享】太极图【教程贴】

用户:友爱的笨笨鸭_n9r友爱的笨笨鸭_n9r查看:0 回复:0 评论:0 创建时间:2023-09-23T17:46:49


【作品展示】

center_image

 

【作品介绍】

太极图

 

【作品源代码】

import turtle as t
import time

t.setup(700, 700)
t.bgcolor('gold')
t.pensize(1)
t.hideturtle()
t.tracer(0)
t.color('black')

# 造“轮子”(画半圆、画小圆)


def semi_circle(x, c, jd):
    t.color(c)
    t.begin_fill()
    t.fd(x)
    t.left(jd)
    t.circle(x, 180)
    t.left(jd)
    t.fd(2*x)
    t.end_fill()


def mini_circle(a, b):
    t.backward(a)
    t.down()
    t.right(90)
    t.color(b)
    t.begin_fill()
    t.circle(40)
    t.end_fill()
    t.left(90)
    t.up()


a = 15
while True:
    t.home()
    t.left(a)
    semi_circle(200, 'black', 90)
    t.left(180)
    t.fd(200)
    semi_circle(200, 'white', 90)
    t.backward(100)
    semi_circle(100, 'black', 90)
    t.backward(300)
    t.left(180)
    semi_circle(100, 'white', 90)

    mini_circle(150, 'black')
    mini_circle(200, 'white')
    a+=15
    time.sleep(0.019)
    t.update()
    if a>360:
        a-=360
    
    if a%30==0:
        t.clear()

t.done()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页