Skip to content

艺术动画skill:35种艺术风格、9种解说语法,用代码让画动起来。

1.6 KB
Raw Blame
<!doctype html>
<html lang="zh-CN"><meta charset="utf-8"><title>Rick & Morty · 风格36</title>
<style>html,body{margin:0;background:#222323}#stage{width:100vw;aspect-ratio:16/9}svg{display:block;width:100%;height:100%}nav{position:fixed;bottom:10px;left:10px;background:#eee6cf;padding:8px;font:14px sans-serif}input{width:240px}</style>
<div id="stage"><svg id="scene" xmlns="http://www.w3.org/2000/svg" viewBox="0 4 1920 1080"></svg></div>
<nav><button id="play">播放</button> <input id="time" type="range" min="0" max="8" step="0.01" value="0"><span id="label">0.00s</span></nav>
<script src="svg-kit.js"></script><script src="room.js"></script><script>
RM.SCENE.init();RM.mottlePattern('mtDark',256,36,40,.12,[45,38,24]);ROOM36.build();ROOM36.el.style.display='';
window.seek=(t,state)=>{if(!Number.isFinite(t)||t<0)throw Error('t must be non-negative');const sip=Math.max(0,Math.sin(t*Math.PI/4))**4;ROOM36.update(t,state||{sip,look:[Math.sin(t*.7)*.5,0]});document.querySelector('#time').value=t;document.querySelector('#label').textContent=t.toFixed(2)+'s';};
let playing=false,last=0,now=0;document.querySelector('#play').onclick=()=>{playing=!playing;last=performance.now();document.querySelector('#play').textContent=playing?'暂停':'播放';};document.querySelector('#time').oninput=e=>{now=+e.target.value;seek(now);};
function tick(t){if(playing){now=(now+(t-last)/1000)%8;seek(now);}last=t;requestAnimationFrame(tick);}seek(0);window.__ready=true;if(location.search.includes('render=1'))document.querySelector('nav').hidden=true;requestAnimationFrame(tick);
</script></html>