Files
obs-lowerthird/public/test-simple.html
T
2026-03-16 18:10:55 +08:00

453 lines
12 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>几何动画预设 - 简单测试</title>
<style>
body {
margin: 0;
padding: 0;
background: #000;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
font-family: system-ui, sans-serif;
}
.test-container {
width: 800px;
height: 200px;
position: relative;
border: 2px solid #333;
border-radius: 10px;
overflow: hidden;
background: #000;
}
.controls {
position: absolute;
top: 10px;
right: 10px;
z-index: 1000;
background: rgba(0, 0, 0, 0.7);
padding: 10px;
border-radius: 5px;
border: 1px solid #444;
}
button {
background: linear-gradient(135deg, #ff69b4, #00bfff);
border: none;
color: white;
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
font-weight: 600;
margin: 5px;
}
button:hover {
opacity: 0.9;
}
.status {
position: absolute;
bottom: 10px;
left: 10px;
color: #00ff88;
font-size: 12px;
background: rgba(0, 0, 0, 0.7);
padding: 5px 10px;
border-radius: 4px;
}
</style>
</head>
<body>
<div class="test-container" id="widgetContainer">
<!-- 几何动画预设将在这里加载 -->
</div>
<div class="controls">
<button onclick="loadGeometricPreset()">加载几何动画预设</button>
<button onclick="reloadPreset()">重新加载</button>
<button onclick="toggleAnimation()">暂停/继续动画</button>
</div>
<div class="status" id="status">就绪</div>
<script>
let currentIframe = null;
let animationPaused = false;
// 几何动画预设HTML
const geometricPresetHTML = `<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'/>
<style>
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
overflow: hidden;
font-family: system-ui, -apple-system, sans-serif;
color: #fff;
background: transparent;
}
.lt-root {
position: relative;
width: 100%;
height: 100%;
padding: 15px 20px;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: flex-end;
}
/* 几何图形背景 */
.geometric-bg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
}
.geo-shape {
position: absolute;
opacity: 0.4;
filter: blur(0.5px);
mix-blend-mode: screen;
animation: floatGeo 8s infinite ease-in-out;
}
@keyframes floatGeo {
0%, 100% {
transform: translate(0, 0) rotate(0deg);
}
50% {
transform: translate(10px, -15px) rotate(180deg);
}
}
/* 内容面板 */
.lt-container {
position: relative;
z-index: 1;
background: rgba(15, 20, 30, 0.9);
backdrop-filter: blur(15px);
border-radius: 14px;
padding: 18px 22px;
border: 1px solid rgba(255, 255, 255, 0.15);
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
max-width: 380px;
min-width: 300px;
transition: all 0.3s ease;
}
.lt-container:hover {
transform: translateY(-2px);
box-shadow: 0 15px 50px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.2);
}
.lt-header {
display: flex;
align-items: center;
margin-bottom: 12px;
}
.geo-icon {
width: 32px;
height: 32px;
background: linear-gradient(135deg, #ff69b4, #00bfff);
border-radius: 8px;
margin-right: 10px;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
animation: rotateIcon 6s infinite linear;
}
.geo-icon span {
transform: rotate(-45deg);
}
@keyframes rotateIcon {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.lt-title {
font-size: 20px;
font-weight: 700;
background: linear-gradient(90deg, #ff69b4, #00bfff);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin-bottom: 2px;
}
.lt-tag {
font-size: 11px;
letter-spacing: 0.08em;
text-transform: uppercase;
color: #00bfff;
font-weight: 600;
}
.lt-description {
font-size: 13px;
line-height: 1.5;
opacity: 0.9;
margin-bottom: 16px;
}
.lt-features {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 10px;
margin-bottom: 16px;
}
.lt-feature {
background: rgba(255, 255, 255, 0.05);
border-radius: 8px;
padding: 10px;
border: 1px solid rgba(255, 255, 255, 0.08);
}
.lt-feature-title {
font-size: 12px;
font-weight: 600;
margin-bottom: 4px;
}
.lt-feature-desc {
font-size: 10px;
opacity: 0.7;
line-height: 1.3;
}
.lt-status {
display: flex;
align-items: center;
justify-content: space-between;
padding-top: 12px;
border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.status-dot {
width: 6px;
height: 6px;
background: #00ff88;
border-radius: 50%;
animation: pulseDot 2s infinite;
}
@keyframes pulseDot {
0%, 100% {
opacity: 1;
}
50% {
opacity: 0.5;
}
}
.status-text {
font-size: 11px;
opacity: 0.8;
}
.lt-time {
font-size: 10px;
opacity: 0.6;
}
</style>
</head>
<body>
<div class="lt-root">
<div class="geometric-bg" id="geoContainer"></div>
<div class="lt-container">
<div class="lt-header">
<div class="geo-icon"><span>◈</span></div>
<div>
<div class="lt-title">几何动画预设</div>
<div class="lt-tag">GEOMETRIC PRESET</div>
</div>
</div>
<div class="lt-description">
动态几何图形动画效果,包含多种形状的浮动动画,适合科技展示和创意直播。
</div>
<div class="lt-features">
<div class="lt-feature">
<div class="lt-feature-title">动态图形</div>
<div class="lt-feature-desc">多种几何形状浮动动画</div>
</div>
<div class="lt-feature">
<div class="lt-feature-title">渐变色彩</div>
<div class="lt-feature-desc">彩虹渐变配色方案</div>
</div>
<div class="lt-feature">
<div class="lt-feature-title">3D效果</div>
<div class="lt-feature-desc">CSS 3D变换动画</div>
</div>
<div class="lt-feature">
<div class="lt-feature-title">实时交互</div>
<div class="lt-feature-desc">鼠标悬停响应效果</div>
</div>
</div>
<div class="lt-status">
<div style="display: flex; align-items: center; gap: 6px;">
<div class="status-dot"></div>
<div class="status-text">动画运行中</div>
</div>
<div class="lt-time" id="timeDisplay">15:30</div>
</div>
</div>
</div>
<script>
// 更新时间显示
function updateTime() {
const now = new Date();
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
document.getElementById('timeDisplay').textContent = \`\${hours}:\${minutes}\`;
}
// 创建几何图形
function createGeometry() {
const container = document.getElementById('geoContainer');
const shapes = ['circle', 'square', 'triangle'];
const colors = [
'rgba(255,105,180,0.25)',
'rgba(0,191,255,0.25)',
'rgba(50,205,50,0.25)',
'rgba(255,215,0,0.25)',
'rgba(138,43,226,0.25)'
];
// 创建10个几何图形
for (let i = 0; i < 10; i++) {
const shape = document.createElement('div');
shape.className = 'geo-shape';
const shapeType = shapes[Math.floor(Math.random() * shapes.length)];
const color = colors[Math.floor(Math.random() * colors.length)];
const size = Math.random() * 60 + 20;
const left = Math.random() * 100;
const top = Math.random() * 100;
const duration = Math.random() * 6 + 4;
const delay = Math.random() * 2;
shape.style.width = \`\${size}px\`;
shape.style.height = \`\${size}px\`;
shape.style.left = \`\${left}%\`;
shape.style.top = \`\${top}%\`;
shape.style.animationDelay = \`\${delay}s\`;
shape.style.animationDuration = \`\${duration}s\`;
if (shapeType === 'triangle') {
shape.style.width = '0';
shape.style.height = '0';
shape.style.borderLeft = \`\${size/2}px solid transparent\`;
shape.style.borderRight = \`\${size/2}px solid transparent\`;
shape.style.borderBottom = \`\${size}px solid \${color}\`;
shape.style.background = 'none';
} else if (shapeType === 'circle') {
shape.style.borderRadius = '50%';
shape.style.background = \`radial-gradient(circle, \${color}, transparent 70%)\`;
} else {
shape.style.borderRadius = '8px';
shape.style.background = color;
}
container.appendChild(shape);
}
}
// 初始化
document.addEventListener('DOMContentLoaded', function() {
updateTime();
createGeometry();
setInterval(updateTime, 60000);
});
</script>
</body>
</html>`;
function loadGeometricPreset() {
const container = document.getElementById('widgetContainer');
container.innerHTML = '';
const iframe = document.createElement('iframe');
iframe.style.width = '100%';
iframe.style.height = '100%';
iframe.style.border = 'none';
iframe.sandbox = 'allow-scripts allow-same-origin';
container.appendChild(iframe);
currentIframe = iframe;
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
iframeDoc.open();
iframeDoc.write(geometricPresetHTML);
iframeDoc.close();
document.getElementById('status').textContent = '几何动画预设已加载';
document.getElementById('status').style.color = '#00ff88';
}
function reloadPreset() {
if (currentIframe) {
const iframeDoc = currentIframe.contentDocument || currentIframe.contentWindow.document;
iframeDoc.open();
iframeDoc.write(geometricPresetHTML);
iframeDoc.close();
document.getElementById('status').textContent = '预设已重新加载';
document.getElementById('status').style.color = '#00bfff';
}
}
function toggleAnimation() {
if (!currentIframe) return;
const iframeDoc = currentIframe.contentDocument || currentIframe.contentWindow.document;
const shapes = iframeDoc.querySelectorAll('.geo-shape');
animationPaused = !animationPaused;
shapes.forEach(shape => {
if (animationPaused) {
shape.style.animationPlayState = 'paused';
} else {
shape.style.animationPlayState = 'running';
}
});
const statusText = animationPaused ? '动画已暂停' : '动画已继续';
document.getElementById('status').textContent = statusText;
document.getElementById('status').style.color = animationPaused ? '#ff69b4' : '#00ff88';
}
// 页面加载时自动加载预设
window.onload = function() {
setTimeout(loadGeometricPreset, 500);
};
</script>
</body>
</html>