gsap实现通过json配置时间轴元素画布设置制作webm动画视频并下载代码

代码语言:html

所属分类:多媒体

代码描述:gsap实现通过json配置时间轴元素画布设置制作webm动画视频并下载代码,浏览器中就能通过son配置动画效果,支持语音解说,最终合成视频下载。

代码标签: gsap 通过 json 配置 时间轴 元素 画布 设置 制作 webm 动画 视频 下载 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>json动画生成系统</title>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/gsap.3.12.2.js"></script>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            background-color: #0a0a1a;
            color: #ffffff;
            margin: 0;
            padding: 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .container {
            width: 100%;
            max-width: 1200px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        h1 {
            color: #64B5F6;
            margin-bottom: 10px;
        }

        .description {
            color: #B0BEC5;
            text-align: center;
            margin-bottom: 30px;
            max-width: 800px;
        }

        .canvas-container {
            position: relative;
            margin: 20px 0;
            box-shadow: 0 0 20px rgba(0, 150, 255, 0.3);
            border-radius: 4px;
            overflow: hidden;
            /* Will be sized by JS based on config */
        }

        canvas {
            display: block;
            background-color: #0a0a1a; /* Default, can be overridden by config */
        }

        .controls {
            display: flex;
            gap: 15px;
            margin: 20px 0;
            flex-wrap: wrap;
            justify-content: center;
        }

        button {
            padding: 12px 24px;
            background: linear-gradient(135deg, #2196F3, #673AB7);
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            transition: all 0.3s ease;
            min-width: 150px;
        }

        button:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0, 150, 255, 0.4);
        }

        button:disabled {
            background: #555;
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
        }

        .config-editor {
            width: 100%;
            margin: 20px 0;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .editor-container {
            width: 100%;
            max-width: 800px; /* Limit editor width for better readability */
            display: flex;
            flex-direction: column;
        }

        .editor-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
        }

        .editor-title {
            font-size: 18px;
            color: #64B5F6;
        }

        textarea {
            width: 100%;
            height: 300px;
            background-color: #1a1a2a;
            color: #ffffff;
            border: 1px solid #333;
            border-radius: 4px;
            padding: 10px;
            font-family: monospace;
            resize: vertical;
            box-sizing: border-box;
        }

        .video-preview {
            margin-top: 30px;
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        video {
            max-width: 100%;
            border-radius: 4px;
            box-shadow: 0 0 20px rgba(0, 150, 255, 0.3);
        }

        .download-link {
            margin-top: 15px;
            padding: 12px 24px;
            background: linear-gradient(135deg, #4CAF50, #009688);
            color: white;
            text-decoration: none;
            border-radius: 4px;
            transition: all 0.3s ease;
        }

        .download-link:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
        }

        .status {
            margin-top: 10px;
            min-height: 1.2em; /* Prevent layout shift */
            color: #64B5F6;
        }

        .error {
            color: #FF5252;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>动画生成系统</h1>
        <p class="description">基于JSON配置的动画生成器 - 通过修改配置文件创建自定义动画,并导出为WebM视频</p>

        <div class="canvas-container">
            <canvas id="animationCanvas"></canvas>
        </div>

        <div class="controls">
            <button id="previewBtn">预览动画</button>
            <button id="recordBtn">录制视频</button>
            <button id="stopBtn" disabled>停止</button>
            <button id="resetBtn">重置</button>
        </div>

 .........完整代码请登录后点击上方下载按钮下载查看

网友评论0