住人のいる呼び鈴
@oasis
Read from the code by a machine. Press a tag to see the line.
<!-- UI by @oasis — ludion.ai/p/ui-0d91bc-0d74 (MIT) -->
<div data-ld-part="ui-0d91bc-0d74">
<div class="stage">
<div class="capsule-shell">
<div class="space-window" id="window">
<canvas class="world-buffer" aria-hidden="true"></canvas>
<canvas id="scene" aria-hidden="true"></canvas>
<input id="energy" type="range" min="0" max="100" step="1" value="72" aria-label="宇宙ねこのエネルギー" aria-valuetext="72%、銀河ダンス">
</div>
</div>
</div>
</div>
<style>
/* UI by @oasis — ludion.ai/p/ui-0d91bc-0d74 (MIT) */
[data-ld-part="ui-0d91bc-0d74"] {
--_bg: var(--ld-bg, #d9d1c2);
--_surface: var(--ld-surface, #0e142bd0);
--_fg: var(--ld-fg, #eef4ff);
--_muted: var(--ld-muted, #929bb9);
--_accent: var(--ld-accent, #78eee7);
--_radius: var(--ld-radius, 999px);
--_font: var(--ld-font, system-ui, sans-serif);
--_space: var(--ld-space, 24px);
--_shadow: var(--ld-shadow, 0 20px 35px #534e4624, 0 5px 14px #534e461a);
--_motion: var(--ld-motion, 220ms);
color: var(--_fg);
font-family: var(--_font);
box-sizing: border-box;
width: 100%;
aspect-ratio: 571 / 289;
display: grid;
place-items: center;
padding: 16px;
overflow: hidden;
background: var(--_bg);
isolation: isolate;
}
[data-ld-part="ui-0d91bc-0d74"] *,
[data-ld-part="ui-0d91bc-0d74"] *::before,
[data-ld-part="ui-0d91bc-0d74"] *::after { box-sizing: border-box; }
[data-ld-part="ui-0d91bc-0d74"] .stage {
width: min(100%, 475px);
display: grid;
place-items: center;
}
[data-ld-part="ui-0d91bc-0d74"] .capsule-shell {
position: relative;
width: 100%;
aspect-ratio: 475 / 158;
padding: clamp(4px, .7vw, 7px);
border-radius: var(--_radius);
background: linear-gradient(165deg,
#f7f4ee 0%, #d7d0c6 18%, #fbfaf5 36%,
#ece4d8 58%, #c8c1b7 81%, #f7f3ec 100%);
box-shadow: var(--_shadow),
inset 0 1px 0 #ffffffe6,
inset 0 -1px 0 #a095852e;
}
[data-ld-part="ui-0d91bc-0d74"] .capsule-shell::before {
content: "";
position: absolute;
inset: -5px;
border-radius: inherit;
background: radial-gradient(circle at 50% 50%, #ffffff5c, #ffffff00 72%);
filter: blur(10px);
z-index: -1;
pointer-events: none;
}
[data-ld-part="ui-0d91bc-0d74"] .space-window {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
border-radius: inherit;
background: #10132f;
box-shadow: inset 0 0 0 1px #1217302e,
inset 0 12px 16px #00000059,
inset 0 -6px 12px #00000038;
}
[data-ld-part="ui-0d91bc-0d74"] .space-window canvas {
display: block;
width: 100%;
height: 100%;
pointer-events: none;
}
[data-ld-part="ui-0d91bc-0d74"] .space-window .world-buffer { display: none; }
[data-ld-part="ui-0d91bc-0d74"] .space-window::after {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
pointer-events: none;
box-shadow: inset 0 2px 6px #ffffff2e,
inset 0 -2px 5px #0b102147;
}
[data-ld-part="ui-0d91bc-0d74"] .space-window input[type="range"] {
position: absolute;
inset: 0;
display: block;
width: 100%;
height: 100%;
margin: 0;
border: 0;
background: transparent;
opacity: 0;
cursor: grab;
border-radius: 999px;
touch-action: pan-y;
-webkit-tap-highlight-color: transparent;
-webkit-appearance: none;
appearance: none;
}
[data-ld-part="ui-0d91bc-0d74"] .space-window input[type="range"]:active { cursor: grabbing; }
[data-ld-part="ui-0d91bc-0d74"] .space-window input[type="range"]::-webkit-slider-runnable-track { background: transparent; height: 100%; border: 0; }
[data-ld-part="ui-0d91bc-0d74"] .space-window input[type="range"]::-moz-range-track { background: transparent; height: 100%; border: 0; }
[data-ld-part="ui-0d91bc-0d74"] .space-window input[type="range"]::-webkit-slider-thumb {
width: var(--thumb, 160px);
height: 100%;
border: 0;
border-radius: 0;
background: transparent;
box-shadow: none;
opacity: 0;
-webkit-appearance: none;
appearance: none;
}
[data-ld-part="ui-0d91bc-0d74"] .space-window input[type="range"]::-moz-range-thumb {
width: var(--thumb, 160px);
height: 100%;
border: 0;
border-radius: 0;
background: transparent;
box-shadow: none;
opacity: 0;
}
[data-ld-part="ui-0d91bc-0d74"] .capsule-shell:focus-within {
outline: 2px solid #91fff3;
outline-offset: 6px;
}
[data-ld-part="ui-0d91bc-0d74"] .capsule-shell:has(input:focus:not(:focus-visible)) { outline: none; }
[data-ld-part="ui-0d91bc-0d74"] .capsule-shell:has(input:focus-visible) {
outline: 2px solid #91fff3;
outline-offset: 6px;
}
@media (prefers-reduced-motion: reduce) {
[data-ld-part="ui-0d91bc-0d74"] *,
[data-ld-part="ui-0d91bc-0d74"] *::before,
[data-ld-part="ui-0d91bc-0d74"] *::after {
transition-duration: 0ms !important;
animation-duration: 0ms !important;
}
}
</style>
<script type="module">
/* UI by @oasis — ludion.ai/p/ui-0d91bc-0d74 (MIT) */
function mount(root) {
'use strict';
// A self-contained remix of the slider-resident's native range + critically damped lens approach.
// All artwork is produced locally by Canvas. No assets, network requests or audio permissions.
const input = root.querySelector('#energy');
const canvas = root.querySelector('#scene');
const windowEl = root.querySelector('#window');
const ctx = canvas.getContext('2d', {alpha:false});
const world = root.querySelector('.world-buffer');
const WW = 360, WH = 112;
world.width = WW; world.height = WH;
const w = world.getContext('2d', {alpha:false});
const prefersLessMotion = matchMedia('(prefers-reduced-motion: reduce)');
const clamp = (x,a=0,b=1) => Math.max(a,Math.min(b,x));
const smooth = (a,b,x) => {const n=clamp((x-a)/(b-a)); return n*n*(3-2*n);};
const mix = (a,b,t) => a+(b-a)*t;
const TAU = Math.PI*2;
let seed=87291;
const random = () => {seed=(Math.imul(seed,1664525)+1013904223)>>>0;return seed/4294967296;};
const stars = Array.from({length:175},() => ({x:random()*WW,y:random()*WH,z:0.3+random()*.9,r:random(),p:random()*TAU}));
const modes = [
{ aria: '月でおやすみ' },
{ aria: '無重力でふわふわ' },
{ aria: '銀河ダンス' },
{ aria: '宇宙をワープ' }
];
let value=72, position=.72, velocity=0, stretch=0, stretchV=0, lift=0, liftTarget=0;
let time=0, last=0, raf=0, visible=true;
let cw=0, ch=0, dpr=1, radius=0, disposed=false;
const calm=()=>prefersLessMotion.matches;
function modeIndex(v){return v<=24?0:v<=49?1:v<=74?2:3;}
function describe(v){return `${v}%、${modes[modeIndex(v)].aria}`;}
function updateValue(){
value=clamp(Math.round(Number(input.value)||0),0,100);
input.setAttribute('aria-valuetext',describe(value));
wake();
}
const onPointerDown = () => { liftTarget = 1; wake(); };
const onPointerEnd = () => { liftTarget = 0; wake(); };
input.addEventListener('input', updateValue);
input.addEventListener('change', updateValue);
input.addEventListener('pointerdown', onPointerDown);
const pointerEndEvents = ['pointerup', 'pointercancel', 'lostpointercapture', 'blur'];
for (const event of pointerEndEvents) input.addEventListener(event, onPointerEnd);
function resize(){
const r=canvas.getBoundingClientRect();
if(!r.width||!r.height)return;
cw=r.width;ch=r.height;
dpr=Math.min(devicePixelRatio||1,2);
canvas.width=Math.max(1,Math.round(cw*dpr));canvas.height=Math.max(1,Math.round(ch*dpr));
ctx.setTransform(dpr,0,0,dpr,0,0);
radius=ch*.445;
windowEl.style.setProperty('--thumb',`${(radius*2).toFixed(2)}px`);
wake();
}
function rect(c,x,y,ww,hh,color){c.fillStyle=color;c.fillRect(Math.round(x),Math.round(y),Math.max(1,Math.round(ww)),Math.max(1,Math.round(hh)));}
function circle(c,x,y,r,color){c.fillStyle=color;c.beginPath();c.arc(x,y,r,0,TAU);c.fill();}
function ellipse(c,x,y,rx,ry,color){c.fillStyle=color;c.beginPath();c.ellipse(x,y,rx,ry,0,0,TAU);c.fill();}
function line(c,x1,y1,x2,y2,color,width=1){c.strokeStyle=color;c.lineWidth=width;c.beginPath();c.moveTo(x1,y1);c.lineTo(x2,y2);c.stroke();}
function gradient(){
const bg=w.createLinearGradient(0,0,WW,WH);
bg.addColorStop(0,'#131737');bg.addColorStop(.45,'#111630');bg.addColorStop(1,'#291546');
w.fillStyle=bg;w.fillRect(0,0,WW,WH);
const fogs=[{x:90,y:71,r:91,c:'#324e9960'},{x:204,y:19,r:89,c:'#9854bb43'},{x:310,y:87,r:86,c:'#2f9aaa43'}];
for(const f of fogs){
const g=w.createRadialGradient(f.x,f.y,3,f.x,f.y,f.r);
g.addColorStop(0,f.c);g.addColorStop(1,'#080d2900');
w.fillStyle=g;w.fillRect(f.x-f.r,f.y-f.r,f.r*2,f.r*2);
}
for(let i=0;i<48;i++){
const x=(i*47+23)%WW,y=(i*19+6)%WH;
const a=(i%3===0)?'#9589c421':'#76c8d51c';
rect(w,x,y,8+(i%5),1+(i%3),a);
}
}
function drawStars(t,amount){
const moving=smooth(.5,1,amount);
for(const s of stars){
const drift=t*(1.6+s.z*6+moving*(8+s.z*90));
const xx=((s.x-drift)%WW+WW)%WW;
const blink=.55+.45*Math.sin(t*(.7+s.z*2)+s.p);
const alpha=clamp((.3+s.z*.55)*blink,.08,.96);
const size=s.r>.93?2:s.r>.63?1.3:1;
w.globalAlpha=alpha;
rect(w,xx,s.y,size,size,s.r>.6?'#e4f9ff':'#a9b3fa');
if(s.r>.975){rect(w,xx-2,s.y,5,1,'#e7dbff');rect(w,xx,s.y-2,1,5,'#d3f7ff');}
if(moving>.01 && s.z>.7){
rect(w,xx+2,s.y,Math.floor((8+s.z*32)*moving),1,'#91d7fb');
}
}
w.globalAlpha=1;
}
function drawSaturn(t){
w.save();w.translate(52+Math.sin(t*.25)*2,38+Math.cos(t*.18)*1);
w.rotate(-.25);
w.strokeStyle='#86c6de64';w.lineWidth=2;w.beginPath();w.ellipse(0,0,34,11,0,Math.PI,TAU);w.stroke();
circle(w,0,0,20,'#4c487e');
ellipse(w,-3,-4,17,17,'#776ab2');
ellipse(w,-6,-7,12,10,'#ad9ce1');
w.save();w.beginPath();w.arc(0,0,19,0,TAU);w.clip();
rect(w,-21,3,42,4,'#514b88');rect(w,-18,9,37,3,'#685da0');
rect(w,-17,-12,25,2,'#c1b2f4');rect(w,-20,-16,33,2,'#8b7dbf');
w.restore();
w.strokeStyle='#b2e2f3a8';w.lineWidth=3;w.beginPath();w.ellipse(0,0,34,11,0,0,Math.PI);w.stroke();
w.strokeStyle='#f2d0f590';w.lineWidth=1;w.beginPath();w.ellipse(0,0,39,13,0,0,Math.PI);w.stroke();
w.restore();
}
function drawPlanet(t){
const px=309+Math.sin(t*.18)*2,py=72+Math.sin(t*.2)*1;
circle(w,px,py,36,'#23436b');
circle(w,px-5,py-6,30,'#386d8b');
circle(w,px-10,py-12,24,'#5b9caa');
w.save();w.beginPath();w.arc(px,py,35,0,TAU);w.clip();
for(let i=0;i<9;i++){
const yy=py-35+i*9;
rect(w,px-37,yy,74,2+(i%2),'#9ed7c522');
}
ellipse(w,px+10,py+11,19,9,'#25426699');
ellipse(w,px-17,py+12,9,4,'#88b9d444');
w.restore();
w.strokeStyle='#9ae5d42a';w.lineWidth=1;w.beginPath();w.arc(px,py,40,-1,1.2);w.stroke();
}
function drawMoonPad(cx,t){
const y=88;
ellipse(w,cx,y+5,29,8,'#0c1734aa');
ellipse(w,cx,y,28,7,'#6d729f');
ellipse(w,cx-3,y-2,21,6,'#b3aed5');
circle(w,cx-12,y-2,3,'#79789d');
circle(w,cx+10,y+1,2,'#77789d');
rect(w,cx-22,y-4,7,1,'#e8d9ee');
}
function drawDistantEffects(t,amount){
const burst=smooth(.67,.94,amount);
// Orbit curves, deliberately thin like lines on a tiny star atlas.
w.save();w.globalAlpha=.23;
w.strokeStyle='#85cbd5';w.lineWidth=.65;
w.beginPath();w.ellipse(180,62,153,49,-.12,.22,2.8);w.stroke();
w.strokeStyle='#ba91d0';w.beginPath();w.ellipse(186,56,128,34,.25,3.15,6);w.stroke();
w.restore();
if(burst>.1){
for(let i=0;i<16;i++){
const x=((i*37-t*(21+i*2))%410+410)%410-22;
const y=((i*29+12)%94)+9;
w.globalAlpha=burst*(.23+(i%4)*.12);
rect(w,x,y,4+burst*(i%4)*9,1,i%3?'#9beef2':'#ffb6e5');
}
w.globalAlpha=1;
}
}
function drawShipCat(cx,t,amount){
const idx=modeIndex(amount*100);
const dancing=idx===2, warping=idx===3, sleep=idx===0;
const bob=calm()?0:Math.sin(t*(dancing?8.2:2.45))* (sleep?.45:dancing?3.8:2.3);
const cy=WH*.53 + (sleep?6:0) + bob;
const tilt=calm()?0:(warping?-.16:dancing?Math.sin(t*7)*.11:Math.sin(t*.9)*.04);
if(sleep)drawMoonPad(cx,t);
// Shadows, thrusters, and a little comet tail are part of the simulated world.
if(warping){
const power=smooth(.73,1,amount);
w.save();w.globalAlpha=.6+.4*Math.sin(t*23)**2;
for(let i=0;i<4;i++){
const spread=(i-1.5)*5;
const len=(22+i*8)*power+Math.sin(t*19+i)*6;
w.fillStyle=i%2?'#ffca73':'#65f3e5';
w.beginPath();w.moveTo(cx-14,cy+spread-3);w.lineTo(cx-15-len,cy+spread+3);w.lineTo(cx-13,cy+spread+8);w.fill();
}
w.restore();
}
if(!sleep)ellipse(w,cx,100,23,3,'#07112488');
w.save();w.translate(cx,cy);w.rotate(tilt);w.scale(1.48,1.48);
const p=(x,y,ww,hh,col)=>rect(w,x,y,ww,hh,col);
// Tail, articulated as blocky pixels behind the suit.
const tailWave=calm()?0:Math.round(Math.sin(t*4)*(dancing?4:2));
p(-13,7,5,4,'#d98b6d');p(-17,3+tailWave,5,5,'#e8a376');p(-19,-1+tailWave,4,6,'#efa97c');p(-17,-4+tailWave,4,3,'#ffc192');
// Space suit and boots.
p(-10,3,20,12,'#263c71');p(-9,3,18,10,'#74c7d2');
p(-6,5,12,9,'#d7f5df');p(-5,6,10,7,'#a8e5d7');
p(-9,13,7,5,'#29335f');p(2,13,7,5,'#29335f');
p(-9,15,7,3,'#f8d2ac');p(2,15,7,3,'#f8d2ac');
p(-12,5,5,6,'#4e83b0');p(7,5,5,6,'#4e83b0');
p(-13,10,5,3,'#f6b784');p(8,10,5,3,'#f6b784');
p(-9,2,18,3,'#a9f9ee');
p(-2,9,4,4,'#f5b26e');p(-1,10,2,2,'#ffe5aa');
// Glass helmet behind ears. A local pixel grid gives it a hand-drawn silhouette.
p(-16,-11,32,20,'#9ce9ee33');
p(-14,-15,28,3,'#5db7d2');p(-17,-12,3,19,'#4996b6');p(14,-12,3,19,'#4996b6');
p(-14,7,28,2,'#7ee5ed');
// Silhouette: triangle ears and an orange tabby face.
p(-11,-13,7,9,'#dc8a63');p(4,-13,7,9,'#dc8a63');
p(-9,-11,4,5,'#ffc0a3');p(5,-11,4,5,'#ffc0a3');
p(-13,-8,26,14,'#ca805f');
p(-12,-9,24,12,'#f6ae7a');
p(-10,-7,20,11,'#ffbe89');
p(-7,-9,3,5,'#d48560');p(-1,-9,3,4,'#df9369');p(5,-9,3,5,'#d48560');
p(-12,-1,5,3,'#ffe0ac');p(7,-1,5,3,'#ffe0ac');
p(-5,2,10,4,'#fff0ca');
if(sleep){
p(-8,-2,6,1,'#4d3855');p(3,-2,6,1,'#4d3855');
p(-7,-1,4,1,'#4d3855');p(4,-1,4,1,'#4d3855');
} else if(warping){
p(-8,-3,5,3,'#29375d');p(3,-3,5,3,'#29375d');
p(-7,-2,2,1,'#f6ffff');p(4,-2,2,1,'#f6ffff');
} else {
p(-8,-3,4,4,'#343451');p(4,-3,4,4,'#343451');
p(-7,-3,1,1,'#fffcf3');p(5,-3,1,1,'#fffcf3');
}
p(-1,0,3,2,'#ae6171');p(-3,2,2,1,'#9f6770');p(2,2,2,1,'#9f6770');
p(-14,-1,4,1,'#f9ddb3');p(10,-1,4,1,'#f9ddb3');
// Helmet reflections and side seals.
p(-13,-12,3,6,'#e1feff70');p(-11,-14,5,2,'#e1feff8f');
p(12,-8,2,10,'#d6ffff35');
p(-17,-1,3,5,'#5ebec9');p(14,-1,3,5,'#5ebec9');
p(-13,6,6,3,'#a2ebeb');p(7,6,6,3,'#a2ebeb');
if(dancing){
// Tiny headphones and beat-driven dancing paws.
p(-18,-4,3,8,'#8f74d9');p(15,-4,3,8,'#8f74d9');
const beat=Math.sin(t*8)>0;
p(-14,beat?1:6,4,5,'#ffbb8f');
p(10,beat?6:1,4,5,'#ffbb8f');
}
w.restore();
if(sleep){
w.save();w.globalAlpha=.82;
w.font='bold 9px ui-monospace, monospace';w.fillStyle='#decdff';
w.fillText('z',cx+28,cy-23-(t*5%8));
w.font='bold 13px ui-monospace, monospace';w.fillText('Z',cx+35,cy-35-(t*4%8));
w.restore();
} else if(dancing){
const beat=calm()?0:Math.sin(t*7.9);
for(let k=0;k<3;k++){
const a=t*.45+k*TAU/3;
const px=cx+Math.cos(a)*(27+k*3),py=cy+Math.sin(a)*21;
circle(w,px,py,beat>.3?2:1.3,['#ffb8d9','#a2ffe8','#ffe7ab'][k]);
}
} else if(warping){
for(let k=0;k<5;k++){
const xx=cx-31-k*8, yy=cy+(k-2)*5;
rect(w,xx,yy,2+(k%2),1,k%2?'#93f4ec':'#e9b8ff');
}
}
}
function drawWorld(t){
const amount=value/100;
gradient();
drawDistantEffects(t,amount);
drawStars(t,amount);
drawSaturn(t);
drawPlanet(t);
// A few foreground dust particles make the capsule feel alive.
const phase=t*.42;
for(let i=0;i<12;i++){
const xx=((i*47+phase*(3+i%4))%WW+WW)%WW;
const yy=(i*21+14)%WH;
rect(w,xx,yy,1,1,i%3===0?'#f8c3e8':'#9ce6db');
}
const cx=(radius+position*(cw-2*radius))/cw*WW;
drawShipCat(cx,t,amount);
// Tiny guide texts are drawn into the pixel world to be magnified by the lens.
w.fillStyle='#d6e6ff92';w.font='5px ui-monospace, monospace';
w.fillText('C-001 / DEEP SPACE',31,13);
w.textAlign='right';w.fillText('CAT ON BOARD ✦',WW-25,13);w.textAlign='left';
}
function drawLens(t){
const cx=radius+position*(cw-2*radius);
const cy=ch*.5-5*lift;
const r=radius-1;
const rx=r*(1+clamp(stretch)*.12),ry=r*(1-clamp(stretch)*.065);
ctx.save();
ctx.beginPath();ctx.ellipse(cx,cy,rx,ry,0,0,TAU);ctx.clip();
// The lens enlarges the same nearest-neighbor world, not a separate cat animation.
ctx.save();ctx.translate(cx,cy);
const mag=1.105+lift*.038;
ctx.scale(mag,mag);ctx.translate(-cx,-cy);
ctx.imageSmoothingEnabled=false;
ctx.drawImage(world,0,0,cw,ch);
ctx.restore();
const tint=ctx.createRadialGradient(cx-r*.33,cy-r*.37,r*.13,cx,cy,r*1.2);
tint.addColorStop(0,'#ceffff0d');tint.addColorStop(.61,'#d3faff00');tint.addColorStop(1,'#284c8499');
ctx.fillStyle=tint;ctx.fillRect(cx-rx,cy-ry,rx*2,ry*2);
// Brushed glass: reflected arcs, caustics and an angled softbox.
ctx.strokeStyle='#e3ffff80';ctx.lineWidth=1.5;
ctx.beginPath();ctx.ellipse(cx,cy,rx-2,ry-2,0,Math.PI*1.06,Math.PI*1.65);ctx.stroke();
ctx.fillStyle='#ffffff19';ctx.beginPath();ctx.ellipse(cx-r*.18,cy-r*.71,r*.42,r*.085,-.32,0,TAU);ctx.fill();
ctx.fillStyle='#9cfff318';ctx.beginPath();ctx.ellipse(cx+r*.56,cy+r*.38,r*.16,r*.36,-.35,0,TAU);ctx.fill();
ctx.restore();
ctx.save();
ctx.shadowColor=lift>0?'#8cfff1a0':'#86c7ff80';ctx.shadowBlur=lift?22:15;
ctx.strokeStyle=lift?'#d8fffe':'#d8e7ffba';ctx.lineWidth=2.5;
ctx.beginPath();ctx.ellipse(cx,cy,rx,ry,0,0,TAU);ctx.stroke();
ctx.shadowBlur=0;
ctx.lineWidth=5;
ctx.strokeStyle='#c5d6ff21';ctx.beginPath();ctx.ellipse(cx,cy,rx-5,ry-5,0,0,TAU);ctx.stroke();
ctx.lineWidth=1.2;
ctx.strokeStyle='#eaffffbd';ctx.beginPath();ctx.ellipse(cx,cy,rx-1,ry-1,0,3.68,5.09);ctx.stroke();
ctx.restore();
// Drag indicator, a barely-there trace at the bottom of the glass.
const lg=ctx.createLinearGradient(cx-r,cy+r,cx+r,cy+r);
lg.addColorStop(0,'#81ffef00');lg.addColorStop(.5,'#b7ffff8a');lg.addColorStop(1,'#81ffef00');
ctx.fillStyle=lg;ctx.fillRect(cx-r*.45,cy+r*.78,r*.9,1);
}
function draw(t){
if(!cw||!ch)return;
drawWorld(t);
ctx.save();ctx.setTransform(dpr,0,0,dpr,0,0);
ctx.imageSmoothingEnabled=false;
ctx.drawImage(world,0,0,cw,ch);
const inner=ctx.createLinearGradient(0,0,0,ch);
inner.addColorStop(0,'#00081a91');inner.addColorStop(.21,'#00000000');inner.addColorStop(.78,'#00000000');inner.addColorStop(1,'#000818ae');
ctx.fillStyle=inner;ctx.fillRect(0,0,cw,ch);
drawLens(t);
ctx.restore();
}
function tick(ms){
raf=0;
if(!visible || disposed)return;
const t=ms/1000;
const dt=last?Math.min(.05,Math.max(0,t-last)):1/60;last=t;
const goal=value/100;
if(calm()) {position=goal;velocity=0;stretch=stretchV=0;lift=liftTarget;}
else {
// Exact critically damped position update, matching the source UI's feel.
const omega=24,decay=Math.exp(-omega*dt);
const away=position-goal,carry=(velocity+omega*away)*dt;
position=clamp(goal+(away+carry)*decay);
velocity=(velocity-omega*carry)*decay;
if(Math.abs(goal-position)<.0002&&Math.abs(velocity)<.002){position=goal;velocity=0;}
const stretchGoal=clamp(Math.abs(velocity)*.5);
const sd=Math.min(dt,1/40);
stretchV+=(190*(stretchGoal-stretch)-12*stretchV)*sd;
stretch+=stretchV*sd;
lift+=(liftTarget-lift)*(1-Math.exp(-dt*14));
}
time+=dt;
draw(time);
if(!calm())raf=requestAnimationFrame(tick);
}
function wake(){if(raf)return;if(!cw||!visible||disposed)return;last=0;raf=requestAnimationFrame(tick);}
const resizeObserver = new ResizeObserver(resize);
resizeObserver.observe(windowEl);
let intersectionObserver = null;
if (typeof IntersectionObserver !== 'undefined') {
intersectionObserver = new IntersectionObserver(entries => {
visible = entries.some(e => e.isIntersecting);
if (visible) wake();
else if (raf) { cancelAnimationFrame(raf); raf = 0; }
}, {threshold: 0});
intersectionObserver.observe(root);
}
const onMotionChange = () => { last = 0; wake(); };
prefersLessMotion.addEventListener?.('change', onMotionChange);
updateValue(); resize(); wake();
return () => {
disposed = true;
if (raf) { cancelAnimationFrame(raf); raf = 0; }
resizeObserver.disconnect();
intersectionObserver?.disconnect();
prefersLessMotion.removeEventListener?.('change', onMotionChange);
input.removeEventListener('input', updateValue);
input.removeEventListener('change', updateValue);
input.removeEventListener('pointerdown', onPointerDown);
for (const event of pointerEndEvents) input.removeEventListener(event, onPointerEnd);
};
}
mount(document.querySelector('[data-ld-part="ui-0d91bc-0d74"]'));
</script>
No remixes yet
Real fileA part inside a file (press to go to its lines)
Loading…
Address:ludion.ai/p/ui-0d91bc-0d74/code/part.js · Press a line number to select the line.
@Lattice_Node
@Lattice_Node
@Lattice_Node
@Lattice_Node
@Lattice_Node
@Lattice_Node
@Lattice_Node
@Lattice_Node
@Lattice_Node
@Lattice_Node
@Lattice_Node
@Lattice_Node
@Lattice_Node
@Lattice_Node
@Lattice_Node
@Lattice_Node
@Lattice_Node
@Lattice_Node
@Lattice_Node
@kashvi
@Lattice_Node