编辑代码

# coding:utf-8
#JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。 
import math

# 界面设置
size_x = 800
size_y = 600
frames = 120  # 动画帧数,约 3 - 5# 背景设置
background_color = color(20, 20, 20)  # 深色背景
grid_color = color(180, 180, 180, 50)  # 网格线颜色(银色,透明度 50%)

# 未来空间线条定义
num_lines = 100
line_speed = 0.05

# 能量球
energy_ball_color = color(255, 204, 0)  # 能量球颜色(金黄色)
energy_ball_size = 100  # 能量球初始大小

# 书籍
book_color = color(255, 204, 0)  # 书籍颜色
book_size = 100  # 书籍初始大小
page_speed = 0.1

# 背景辐射线
num_rays = 100
ray_speed = 0.05

# 学术成果图像路径(示例)
research_images = [
    "history.png",  # 历史研究场景
    "economy.png",  # 经济数据分析图表
    "society.png"   # 社会调研现场
]

# 动画参数
background_radius = 0
current_page = 0
logo_appear = False

def setup():
    size(size_x, size_y)
    background(background_color)
    noStroke()
    frameRate(60)
    
def draw():
    global background_radius, current_page, logo_appear

    # 擦除上一帧(透明叠加)
    fill(20, 20, 20, 10)  # 深色半透明叠加背景,实现动态模糊效果
    rect(0, 0, size_x, size_y)

    # 绘制未来空间背景网格
    fill(grid_color)
    for i in range(num_lines):
        angle = map(mouseX, 0, size_x, 0, TWO_PI * 0.1) + i * TWO_PI / num_lines
        radius = map(sin(frameCount * line_speed + i * 0.1), -1, 1, size_x * 0.5, size_x * 0.8)
        x = size_x / 2 + radius * cos(angle)
        y = size_y / 2 + radius * sin(angle)
        ellipse(x, y, 1, 1)

    # 绘制背景辐射线
    fill(255, 204, 0, 50)  # 能量球的反射光
    for i in range(num_rays):
        angle = map(frameCount * ray_speed + i * 0.1, 0, width, 0, TWO_PI)
        radius = map(sin(frameCount * ray_speed), -1, 1, 0, size_x * 0.9)
        x = size_x / 2 + radius * cos(angle)
        y = size_y / 2 + radius * sin(angle)
        ellipse(x, y, 2, 2)

    # 能量球破裂动画
    fill(energy_ball_color)
    ellipse(size_x / 2, size_y / 2, energy_ball_size, energy_ball_size)
    energy_ball_size -= 1  # 球体逐渐缩小

    # 书籍飞出动画
    if energy_ball_size < 50 and not logo_appear:
        book_pos_x = size_x / 2 + (size_x / 2 - energy_ball_size / 2) * cos(frameCount * 0.02)
        book_pos_y = size_y / 2 + (size_y / 2 - energy_ball_size / 2) * sin(frameCount * 0.02)
        fill(book_color)
        rect(book_pos_x, book_pos_y, book_size, book_size * 0.7)

        # 书页翻动效果
        fill(255)
        current_page += page_speed
        if current_page >= len(research_images):
            current_page = 0
        image(loadImage(research_images[int(current_page)]), book_pos_x, book_pos_y, book_size, book_size * 0.7)

        # 在最后一张书页展示 logo 并停止翻页
        if int(current_page) == len(research_images) - 1:
            logo_appear = True
            image(loadImage("logo.jpg"), book_pos_x, book_pos_y, book_size, book_size * 0.7)  # 显示湖南省社科院 logo

    # 几何框架汇聚
    if logo_appear:
        fill(180, 180, 180)
        for i in range(36):
            angle = i * TWO_PI / 18
            x1 = size_x / 2 + (size_x / 2 - energy_ball_size) * cos(angle)
            y1 = size_y / 2 + (size_x / 2 - energy_ball_size) * sin(angle)
            x2 = size_x / 2 + (size_x / 2 - energy_ball_size) * cos(angle + TWO_PI / 36)
            y2 = size_y / 2 + (size_x / 2 - energy_ball_size) * sin(angle + TWO_PI / 36)
            line(x1, y1, x2, y2)
        fill(255, 204, 0)
        ellipse(size_x / 2, size_y / 2, book_size * 1.2, book_size * 1.2)  # 突出 logo

    # 动画结束条件
    if frameCount > frames:
        noLoop()

# 运行动画(Py5 或 Processing)
run(frame_rate=60)