猫史档案馆


【Python作品分享】旋转的太极【作品秀】

用户:时间356l时间356l查看:0 回复:0 评论:0 创建时间:2022-11-13T09:40:46


【作品展示】

center_image

 

【作品介绍】

太极是阐明宇宙从无极而太极,以至万物化生的过程。其中的太极即为天地未开、混沌未分阴阳之前的状态。易经系辞:"是故易有太极,是生两仪"。两仪即为太极的阴、阳二仪。"太极"是易学的基本概念,最初见于《周易·系辞上》:"易有太极,是生两仪,两仪生四象,四象生八卦,八卦定吉凶,吉凶生大业。"同时与"大衍筮法"相关,即《上系》所载:"大衍之数五十,其用四十有九。分而为二以象两,挂一以象三,揲之以四,以象四时,归奇于扔以象闰。五岁再闰,故再扐而后挂……是故四营而成易,十有八变而成卦。"围绕大衍筮法,历代以不同侧重对.

 

【作品源代码】

from turtle import *
import time
setup(600, 600, 750, 150)
bgcolor("blue")

# 定义无痕移动画笔函数


def my_goto(x, y):
    up()
    goto(x, y)
    down()
# 定义参考线函数


def ref_line():
    ht()
    speed(0)
    pencolor("Grey")
    pensize(1)
    # 横向参考线
    row_y = 300
    for i in range(int(600 / 100 - 1)):
        row_y -= 100
        my_goto(-300, row_y)
        fd(600)
    left(90)
    # 纵向参考线
    column_x = -300
    for i in range(int(600 / 100 - 1)):
        column_x += 100
        my_goto(column_x, -300)
        fd(600)
    right(90)
    # 回到原点
    my_goto(0, 0)


def taiji():
    # 黑色一侧
    color('black')
    begin_fill()
    circle(240, 180)
    end_fill()
    # 白色一侧
    color('white')
    begin_fill()
    circle(240, 180)
    end_fill()
    # 黑色半圆
    color('black')
    begin_fill()
    circle(120, -180)
    end_fill()
    # 白色半圆
    color('white')
    begin_fill()
    circle(-120, -180)
    end_fill()

    # 黑色小圆
    up()
    rt(90)
    fd(160)
    lt(90)
    down()
    color('black')
    begin_fill()
    circle(40)
    end_fill()

    # 白色小圆
    up()
    rt(90)
    fd(240)
    lt(90)
    down()
    color('white')
    begin_fill()
    circle(40)
    end_fill()

ref_line()
goto(0, -240)
taiji()
ht()

# 定义旋转函数
def spin(d):
    up()
    home()
    right(90 + d * n)
    fd(240)
    left(90)
    taiji()




# 创建动画循环
n = 0
try:
    while True:
        tracer(0)
        clear()
        spin(5)
        n += 1
        update()
        time.sleep(0.01)

except:
    print("Exit")

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页