rootformer-code-v25-showcase / moving_pelican_html_ours.html
enver's picture
Publish Rootformer-Code v25 vs Qwen4-35B-A3B live interactive HTML5/SVG Showcase Space
84b4733 verified
Raw History Blame Contribute Delete
14.9 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Pelican on a Bicycle — Golden Boardwalk</title>
<style>
html,body{margin:0;padding:0;background:#0b0e1a;height:100%;overflow:hidden}
body{display:flex;align-items:center;justify-content:center}
#wrap{position:relative;width:900px;height:650px;box-shadow:0 20px 60px rgba(0,0,0,.6);border-radius:10px;overflow:hidden}
canvas{display:block;background:#000}
#bar{
position:absolute;right:12px;bottom:12px;display:flex;align-items:center;gap:12px;
padding:8px 14px;border-radius:12px;
background:rgba(12,16,28,.55);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);
border:1px solid rgba(255,255,255,.18);box-shadow:0 6px 18px rgba(0,0,0,.35);
font:12px/1 "Segoe UI",system-ui,sans-serif;color:#e8ecf5;user-select:none;
}
#bar label{display:flex;align-items:center;gap:8px;letter-spacing:.3px}
#speed{width:110px;accent-color:#ffb347;cursor:pointer}
#spdVal{min-width:34px;text-align:right;color:#ffd28a;font-variant-numeric:tabular-nums}
#toggle{
background:linear-gradient(180deg,#ffb347,#ff8c2e);color:#2a1500;border:none;border-radius:8px;
padding:6px 12px;font-weight:700;font-size:12px;cursor:pointer;letter-spacing:.4px;
box-shadow:0 2px 6px rgba(255,140,46,.4);transition:transform .1s;
}
#toggle:hover{transform:translateY(-1px)}
#toggle:active{transform:translateY(0)}
#fps{min-width:52px;text-align:right;color:#9fe8ff;font-variant-numeric:tabular-nums}
</style>
</head>
<body>
<div id="wrap">
<canvas id="cv" width="900" height="650"></canvas>
<div id="bar">
<label>Speed <input type="range" id="speed" min="0.5" max="2.5" step="0.1" value="1"><span id="spdVal">1.0x</span></label>
<button id="toggle">Pause</button>
<span id="fps">-- FPS</span>
</div>
</div>
<script>
(function(){
"use strict";
const cv=document.getElementById('cv'),ctx=cv.getContext('2d');
const W=900,H=650;
const HORIZON=372,DECK=560;
const speedEl=document.getElementById('speed'),spdVal=document.getElementById('spdVal'),
toggleEl=document.getElementById('toggle'),fpsEl=document.getElementById('fps');
let speed=1,paused=false,t=0,last=performance.now(),fps=60,fpsAcc=0,fpsN=0,fpsT=0;
speedEl.addEventListener('input',()=>{speed=parseFloat(speedEl.value);spdVal.textContent=speed.toFixed(1)+'x';});
toggleEl.addEventListener('click',()=>{paused=!paused;toggleEl.textContent=paused?'Play':'Pause';});
/* ---------- helpers ---------- */
function lerp(a,b,k){return a+(b-a)*k;}
function clamp(v,a,b){return v<a?a:v>b?b:v;}
function rr(x,y,w,h,r){ctx.beginPath();ctx.moveTo(x+r,y);ctx.arcTo(x+w,y,x+w,y+h,r);ctx.arcTo(x+w,y+h,x,y+h,r);ctx.arcTo(x,y+h,x,y,r);ctx.arcTo(x,y,x+w,y,r);ctx.closePath();}
function seg(x1,y1,x2,y2){ctx.beginPath();ctx.moveTo(x1,y1);ctx.lineTo(x2,y2);ctx.stroke();}
function circ(x,y,r){ctx.beginPath();ctx.arc(x,y,r,0,6.2832);ctx.fill();}
function ell(x,y,rx,ry,rot){ctx.beginPath();ctx.ellipse(x,y,rx,ry,rot||0,0,6.2832);ctx.fill();}
function wave(x,y,amp,per,ph){ctx.beginPath();ctx.moveTo(x,y);for(let i=0;i<=12;i++){const px=x+i*10;ctx.lineTo(px,y+Math.sin(px/per+ph)*amp);} }
/* ---------- static scenery data ---------- */
const planks=[];for(let i=0;i<14;i++){planks.push({w:52+Math.random()*26,g:0.85+Math.random()*0.3,na:Math.random()<0.35});}
const clouds=[];for(let i=0;i<6;i++)clouds.push({x:Math.random()*1100,y:40+Math.random()*150,s:0.6+Math.random()*0.9,v:4+Math.random()*7});
const gulls=[];for(let i=0;i<5;i++)gulls.push({x:Math.random()*900,y:60+Math.random()*160,v:26+Math.random()*30,ph:Math.random()*6.28,s:0.7+Math.random()*0.6});
const birds=[];for(let i=0;i<4;i++)birds.push({x:100+i*210+Math.random()*60,y:HORIZON-4-Math.random()*10,ph:Math.random()*6.28});
const stars=[];for(let i=0;i<26;i++)stars.push({x:Math.random()*W,y:Math.random()*120,r:0.5+Math.random()*1.1,ph:Math.random()*6.28});
/* ---------- sky ---------- */
function drawSky(){
const g=ctx.createLinearGradient(0,0,0,HORIZON+30);
g.addColorStop(0,'#241a4d');g.addColorStop(0.35,'#6b2d5e');g.addColorStop(0.62,'#c94f4a');
g.addColorStop(0.82,'#ff8f3c');g.addColorStop(1,'#ffc46b');
ctx.fillStyle=g;ctx.fillRect(0,0,W,HORIZON+30);
// stars
for(const s of stars){ctx.globalAlpha=0.25+0.35*Math.abs(Math.sin(t*1.5+s.ph));ctx.fillStyle='#fff';circ(s.x,s.y,s.r);}
ctx.globalAlpha=1;
// sun + glow
const sx=640,sy=300;
const gl=ctx.createRadialGradient(sx,sy,10,sx,sy,240);
gl.addColorStop(0,'rgba(255,236,170,0.95)');gl.addColorStop(0.35,'rgba(255,180,90,0.45)');gl.addColorStop(1,'rgba(255,150,60,0)');
ctx.fillStyle=gl;ctx.fillRect(sx-250,sy-250,500,500);
const sg=ctx.createRadialGradient(sx-12,sy-12,4,sx,sy,58);
sg.addColorStop(0,'#fff8dc');sg.addColorStop(0.7,'#ffd76a');sg.addColorStop(1,'#ff9e3d');
ctx.fillStyle=sg;circ(sx,sy,58);
// clouds
for(const c of clouds){
const cx=((c.x-t*c.v)%(W+300)+W+300)%(W+300)-150;
ctx.fillStyle='rgba(255,190,150,0.5)';
ell(cx,c.y,46*c.s,15*c.s);ell(cx-30*c.s,c.y+6*c.s,30*c.s,11*c.s);ell(cx+32*c.s,c.y+5*c.s,32*c.s,12*c.s);
ctx.fillStyle='rgba(255,230,200,0.35)';ell(cx-4*c.s,c.y-8*c.s,34*c.s,10*c.s);
}
// gulls
ctx.strokeStyle='rgba(60,40,60,0.85)';ctx.lineWidth=2;ctx.lineCap='round';
for(const g of gulls){
const gx=((g.x-t*g.v)%(W+120)+W+120)%(W+120)-60;
const f=Math.sin(t*9+g.ph)*5*g.s;
ctx.beginPath();ctx.moveTo(gx-9*g.s,g.y-f);ctx.quadraticCurveTo(gx-3*g.s,g.y+3*g.s,gx,g.y);
ctx.quadraticCurveTo(gx+3*g.s,g.y+3*g.s,gx+9*g.s,g.y-f);ctx.stroke();
}
}
/* ---------- ocean ---------- */
function drawOcean(){
const g=ctx.createLinearGradient(0,HORIZON,0,DECK-14);
g.addColorStop(0,'#ff9a4d');g.addColorStop(0.25,'#c65a58');g.addColorStop(0.6,'#5a3a6e');g.addColorStop(1,'#2c2350');
ctx.fillStyle=g;ctx.fillRect(0,HORIZON,W,DECK-14-HORIZON);
// sun glitter
ctx.save();ctx.globalCompositeOperation='lighter';
for(let i=0;i<14;i++){
const y=HORIZON+8+i*6.5;
const w=90-i*4.5+Math.sin(t*2.2+i*1.7)*14;
ctx.fillStyle='rgba(255,190,110,'+(0.35-i*0.022)+')';
ctx.fillRect(640-w/2,y,w,2.4);
}
ctx.restore();
// wave bands
const bands=[[HORIZON+26,3,26,0.9,'rgba(255,170,120,0.35)'],[HORIZON+48,4,34,1.4,'rgba(255,150,140,0.30)'],
[HORIZON+74,5,44,2.0,'rgba(190,120,170,0.30)'],[HORIZON+100,6,56,2.6,'rgba(140,110,190,0.30)']];
for(const b of bands){
ctx.strokeStyle=b[4];ctx.lineWidth=2.5;
wave(-20,b[0],b[1],b[2],t*b[3]);ctx.stroke();
}
// distant birds on horizon
ctx.strokeStyle='rgba(40,25,50,0.8)';ctx.lineWidth=1.6;
for(const b of birds){
const f=Math.sin(t*7+b.ph)*3;
ctx.beginPath();ctx.moveTo(b.x-6,b.y-f);ctx.quadraticCurveTo(b.x-2,b.y+2,b.x,b.y);
ctx.quadraticCurveTo(b.x+2,b.y+2,b.x+6,b.y-f);ctx.stroke();
}
}
/* ---------- boardwalk ---------- */
function drawBoardwalk(){
// deck
const g=ctx.createLinearGradient(0,DECK,0,H);
g.addColorStop(0,'#8a5a34');g.addColorStop(0.5,'#6e4526');g.addColorStop(1,'#4a2e18');
ctx.fillStyle=g;ctx.fillRect(0,DECK,W,H-DECK);
// sunset sheen
const sh=ctx.createLinearGradient(0,DECK,0,DECK+70);
sh.addColorStop(0,'rgba(255,170,90,0.35)');sh.addColorStop(1,'rgba(255,170,90,0)');
ctx.fillStyle=sh;ctx.fillRect(0,DECK,W,70);
// scrolling planks
const off=(t*150)%80;
ctx.strokeStyle='rgba(30,16,6,0.55)';ctx.lineWidth=2;
for(let x=-80-off;x<W+80;x+=80){
seg(x,DECK,x-14,H);
}
// horizontal seams + grain
ctx.strokeStyle='rgba(30,16,6,0.35)';ctx.lineWidth=1.5;
const rows=[[DECK+34,40],[DECK+72,78],[DECK+112,118],[DECK+156,162]];
for(const r of rows){
const o2=(t*150*0.5)%(r[1]);
for(let x=-r[1]-o2;x<W+r[1];x+=r[1]){seg(x,r[0],x+26,r[0]);}
}
// nails
ctx.fillStyle='rgba(20,10,4,0.6)';
const off2=(t*150)%80;
for(let x=-80-off2;x<W+80;x+=80){circ(x+10,DECK+16,1.6);circ(x+10,DECK+52,1.6);circ(x+10,DECK+92,1.6);}
// top edge highlight
ctx.fillStyle='rgba(255,200,130,0.5)';ctx.fillRect(0,DECK,W,3);
// posts + rail
const poff=(t*150)%260;
for(let x=-260-poff;x<W+260;x+=260){
const pg=ctx.createLinearGradient(x,0,x+16,0);
pg.addColorStop(0,'#5a3a20');pg.addColorStop(0.5,'#7a5230');pg.addColorStop(1,'#4a2e18');
ctx.fillStyle=pg;ctx.fillRect(x,DECK-96,16,96);
ctx.fillStyle='rgba(255,190,120,0.35)';ctx.fillRect(x,DECK-96,3,96);
}
ctx.fillStyle='#5f3d22';ctx.fillRect(0,DECK-92,W,10);
ctx.fillStyle='rgba(255,200,130,0.4)';ctx.fillRect(0,DECK-92,W,2.5);
ctx.fillStyle='rgba(20,10,4,0.4)';ctx.fillRect(0,DECK-83,W,2);
}
/* ---------- bicycle ---------- */
const RW={x:320,y:508},FW={x:570,y:508},BB={x:430,y:505},R=52,CRANK=34;
function wheel(cx,cy,rot){
ctx.save();ctx.translate(cx,cy);
// tire
ctx.strokeStyle='#1c1c22';ctx.lineWidth=9;ctx.beginPath();ctx.arc(0,0,R,0,6.2832);ctx.stroke();
ctx.strokeStyle='rgba(255,255,255,0.12)';ctx.lineWidth=2;ctx.beginPath();ctx.arc(0,0,R-5,0,6.2832);ctx.stroke();
// rim
ctx.strokeStyle='#c9a24a';ctx.lineWidth=3;ctx.beginPath();ctx.arc(0,0,R-6,0,6.2832);ctx.stroke();
// spokes
ctx.rotate(rot);
ctx.strokeStyle='rgba(210,215,225,0.85)';ctx.lineWidth=1.4;
for(let i=0;i<12;i++){const a=i*Math.PI/6;seg(0,0,Math.cos(a)*(R-7),Math.sin(a)*(R-7));}
// hub
ctx.fillStyle='#3a3a44';circ(0,0,6);ctx.fillStyle='#8a8a96';circ(0,0,2.5);
ctx.restore();
}
function drawBike(crankA,pedalA){
// shadow
ctx.fillStyle='rgba(20,10,5,0.35)';ell(445,DECK+8,150,12);
// frame
ctx.lineCap='round';
ctx.strokeStyle='#b3242c';ctx.lineWidth=7;
seg(RW.x,RW.y,BB.x,BB.y);seg(BB.x,BB.y,400,402);seg(400,402,RW.x,RW.y);
seg(BB.x,BB.y,545,398);seg(545,398,FW.x,FW.y);
ctx.strokeStyle='#8f1c22';ctx.lineWidth=3;
seg(RW.x,RW.y,400,402);
// chain
ctx.strokeStyle='#2a2a30';ctx.lineWidth=3;
seg(RW.x,RW.y-8,BB.x,BB.y-8);seg(RW.x,RW.y+8,BB.x,BB.y+8);
// rear cog
ctx.fillStyle='#3a3a44';circ(RW.x,RW.y,10);ctx.fillStyle='#66666e';circ(RW.x,RW.y,4);
// seatpost + saddle
ctx.strokeStyle='#3a3a44';ctx.lineWidth=5;seg(400,402,392,378);
ctx.fillStyle='#2a2018';ell(392,374,26,8,-0.06);
// handlebar
ctx.strokeStyle='#3a3a44';ctx.lineWidth=5;seg(545,398,548,376);
ctx.strokeStyle='#22222a';ctx.lineWidth=6;seg(548,376,566,368);
ctx.fillStyle='#111';circ(566,368,4);
// crankset
ctx.fillStyle='#3a3a44';circ(BB.x,BB.y,15);
ctx.fillStyle='#55555e';circ(BB.x,BB.y,6);
// crank arms + pedals
for(const a of [crankA,pedalA]){
const px=BB.x+Math.cos(a)*CRANK,py=BB.y+Math.sin(a)*CRANK;
ctx.strokeStyle='#4a4a54';ctx.lineWidth=6;seg(BB.x,BB.y,px,py);
ctx.fillStyle='#1e1e24';rr(px-11,py-4,22,8,3);ctx.fill();
ctx.fillStyle='#66666e';circ(px,py,2.5);
}
wheel(RW.x,RW.y,crankA*2.1);
wheel(FW.x,FW.y,crankA*2.1);
}
/* ---------- pelican ---------- */
function leg(hip,foot,side){
const L1=52,L2=52;
let dx=foot.x-hip.x,dy=foot.y-hip.y,d=Math.hypot(dx,dy);
d=clamp(d,10,L1+L2-1);
const a=Math.acos(clamp((L1*L1+d*d-L2*L2)/(2*L1*d),-1,1));
const base=Math.atan2(dy,dx);
const ang=base-a*side;
const knee={x:hip.x+Math.cos(ang)*L1,y:hip.y+Math.sin(ang)*L1};
ctx.strokeStyle='#ff8c1a';ctx.lineWidth=7;ctx.lineCap='round';
ctx.beginPath();ctx.moveTo(hip.x,hip.y);ctx.lineTo(knee.x,knee.y);ctx.lineTo(foot.x,foot.y);ctx.stroke();
// webbed foot
ctx.save();ctx.translate(foot.x,foot.y);ctx.rotate(Math.atan2(foot.y-hip.y,foot.x-hip.x));
ctx.fillStyle='#ff7a00';
ctx.beginPath();ctx.moveTo(0,-4);ctx.lineTo(16,-6);ctx.lineTo(13,0);ctx.lineTo(17,5);ctx.lineTo(0,5);ctx.closePath();ctx.fill();
ctx.strokeStyle='#d95f00';ctx.lineWidth=1;seg(4,-3,13,-4);seg(4,0,15,3);
ctx.restore();
}
function drawPelican(crankA,pedalA){
const bob=Math.sin(crankA*2)*2.5;
const hipF={x:398,y:392+bob*0.5},hipB={x:406,y:396+bob*0.5};
const pF={x:BB.x+Math.cos(crankA)*CRANK,y:BB.y+Math.sin(crankA)*CRANK};
const pB={x:BB.x+Math.cos(pedalA)*CRANK,y:BB.y+Math.sin(pedalA)*CRANK};
// far leg
ctx.globalAlpha=0.85;leg(hipB,pB,1);ctx.globalAlpha=1;
// tail
ctx.fillStyle='#e8e2d4';
ctx.beginPath();ctx.moveTo(352,368+bob);ctx.lineTo(318,352+bob);ctx.lineTo(330,372+bob);ctx.lineTo(314,378+bob);ctx.lineTo(336,382+bob);ctx.closePath();ctx.fill();
// body
const bg=ctx.createLinearGradient(340,330,430,410);
bg.addColorStop(0,'#fffaf0');bg.addColorStop(1,'#e6ddc8');
ctx.fillStyle=bg;ell(392,372+bob,52,34,-0.12);
// wind-ruffled feathers
ctx.strokeStyle='rgba(180,165,140,0.7)';ctx.lineWidth=1.5;
for(let i=0;i<4;i++){
const fx=352+i*10,fy=398+bob+Math.sin(t*6+i)*2;
ctx.beginPath();ctx.moveTo(fx,fy);ctx.quadraticCurveTo(fx-6,fy+6,fx-12,fy+3+Math.sin(t*7+i)*2);ctx.stroke();
}
// neck
ctx.strokeStyle='#fffaf0';ctx.lineWidth=16;ctx.lineCap='round';
ctx.beginPath();ctx.moveTo(418,352+bob);ctx.quadraticCurveTo(452,330+bob,452,300+bob);ctx.stroke();
// head
const hx=452,hy=296+bob;
ctx.fillStyle='#fffaf0';circ(hx,hy,17);
// eye
ctx.fillStyle='#2a1a10';circ(hx+6,hy-4,3.4);
ctx.fillStyle='#fff';circ(hx+7,hy-5,1.2);
// beak + pouch
const beakY=hy+2;
ctx.fillStyle='#ff8c1a';
ctx.beginPath();ctx.moveTo(hx+8,beakY-6);ctx.lineTo(hx+62,beakY+2);ctx.lineTo(hx+8,beakY+4);ctx.closePath();ctx.fill();
ctx.fillStyle='#ff7a00';
ctx.beginPath();ctx.moveTo(hx+8,beakY+3);
ctx.quadraticCurveTo(hx+34,beakY+22+Math.sin(t*3)*2,hx+58,beakY+3);
ctx.closePath();ctx.fill();
ctx.strokeStyle='rgba(200,90,0,0.5)';ctx.lineWidth=1.2;
ctx.beginPath();ctx.moveTo(hx+12,beakY+5);ctx.quadraticCurveTo(hx+32,beakY+16,hx+52,beakY+4);ctx.stroke();
// flapping wing
const flap=Math.sin(t*7)*0.55;
ctx.save();ctx.translate(392,362+bob);ctx.rotate(-0.25+flap*0.5);
const wg=ctx.createLinearGradient(0,0,-70,10);
wg.addColorStop(0,'#f4eee0');wg.addColorStop(1,'#cfc4a8');
ctx.fillStyle=wg;
ctx.beginPath();ctx.moveTo(10,-8);
ctx.quadraticCurveTo(-40,-14+flap*10,-72,4+flap*16);
ctx.quadraticCurveTo(-40,16,8,14);ctx.closePath();ctx.fill();
ctx.strokeStyle='rgba(150,135,110,0.6)';ctx.lineWidth=1.4;
for(let i=0;i<3;i++){ctx.beginPath();ctx.moveTo(-10-i*14,2);ctx.quadraticCurveTo(-30-i*14,8+flap*6,-52-i*8,10+flap*12);ctx.stroke();}
ctx.restore();
// near leg
leg(hipF,pF,-1);
// handlebar grip
ctx.strokeStyle='#ff8c1a';ctx.lineWidth=6;ctx.lineCap='round';
ctx.beginPath();ctx.moveTo(430,352+bob);ctx.quadraticCurveTo(500,340+bob,562,366);ctx.stroke();
}
/* ---------- render ---------- */
function render(){
drawSky();
drawOcean();
drawBoardwalk();
const crankA=t*4.2;
drawBike(crankA,crankA+Math.PI);
drawPelican(crankA,crankA+Math.PI);
}
/* ---------- loop ---------- */
function loop(now){
const dt=Math.min((now-last)/1000,0.1);last=now;
if(!paused)t+=dt*speed;
render();
// fps
fpsAcc+=dt;fpsN++;
if(now-fpsT>400){fps=fpsN/fpsAcc;fpsAcc=0;fpsN=0;fpsT=now;fpsEl.textContent=Math.round(fps)+' FPS';}
requestAnimationFrame(loop);
}
requestAnimationFrame(loop);
})();
</script>
</body>
</html>