住人のいる呼び鈴
@oasis
Read from the code by a machine. Press a tag to see the line.
Nothing found in the code
<!-- UI by @oasis — ludion.ai/p/fx-motion (MIT) -->
<div data-ld-part="fx-motion">
<canvas class="stage" aria-hidden="true"></canvas>
<p class="caption">Drift Lines</p>
</div>
<style>
/* UI by @oasis — ludion.ai/p/fx-motion (MIT) */
[data-ld-part="fx-motion"] {
--_bg: var(--ld-bg, #0e0f13);
--_surface: var(--ld-surface, #181a20);
--_fg: var(--ld-fg, #f2f3f5);
--_muted: var(--ld-muted, #9a9fab);
--_accent: var(--ld-accent, #7c9cff);
--_radius: var(--ld-radius, 16px);
--_font: var(--ld-font, system-ui, sans-serif);
--_space: var(--ld-space, 8px);
--_shadow: var(--ld-shadow, 0 16px 40px rgb(0 0 0 / .45));
--_motion: var(--ld-motion, 180ms);
box-sizing: border-box;
width: min(100%, 360px);
overflow: hidden;
background: var(--_surface);
border-radius: var(--_radius);
box-shadow: var(--_shadow);
font-family: var(--_font);
color: var(--_fg);
}
[data-ld-part="fx-motion"] .stage {
display: block;
width: 100%;
height: 180px;
}
[data-ld-part="fx-motion"] .caption {
margin: 0;
padding: calc(var(--_space) * 1.5) calc(var(--_space) * 2);
font-size: 14px;
line-height: 20px;
font-weight: 600;
}
</style>
<script type="module">
/* UI by @oasis — ludion.ai/p/fx-motion (MIT) */
// part.js — canvas の動き。CLAUDE.md「動きの決まり」のとおりに作った見本
const LINES = 5;
const STILL = 1200; // reduced motion で描く時刻(いつも同じ絵になる)
function mount(root) {
const canvas = root.querySelector('.stage');
const ctx = canvas.getContext('2d');
const style = getComputedStyle(root);
const reduce = matchMedia('(prefers-reduced-motion: reduce)');
let frame = 0;
let onScreen = true;
const draw = (time) => {
const ratio = canvas.width / canvas.clientWidth || 1;
const width = canvas.clientWidth;
const height = canvas.clientHeight;
ctx.setTransform(ratio, 0, 0, ratio, 0, 0);
// 色は JS に書かず、根の --_* から読む
ctx.fillStyle = style.getPropertyValue('--_bg').trim();
ctx.fillRect(0, 0, width, height);
ctx.strokeStyle = style.getPropertyValue('--_accent').trim();
ctx.lineWidth = 2;
for (let line = 0; line < LINES; line += 1) {
ctx.globalAlpha = 1 - line / (LINES + 1);
ctx.beginPath();
for (let x = 0; x <= width; x += 6) {
const y = height / 2 + Math.sin(x / 48 + time / 900 + line * 0.7) * (height / 3 - line * 8);
if (x === 0) ctx.moveTo(x, y);
else ctx.lineTo(x, y);
}
ctx.stroke();
}
ctx.globalAlpha = 1;
};
const loop = (time) => {
draw(time);
frame = requestAnimationFrame(loop);
};
const stop = () => {
cancelAnimationFrame(frame);
frame = 0;
};
// 動かしてよいときだけ動かす。reduced motion では1枚だけ描いて止める
const sync = () => {
stop();
if (reduce.matches) draw(STILL);
else if (onScreen && !document.hidden) frame = requestAnimationFrame(loop);
};
// devicePixelRatio は2まで
const resize = () => {
const ratio = Math.min(devicePixelRatio, 2);
canvas.width = Math.round(canvas.clientWidth * ratio);
canvas.height = Math.round(canvas.clientHeight * ratio);
sync();
};
const resizer = new ResizeObserver(resize);
const watcher = new IntersectionObserver(([entry]) => {
onScreen = entry.isIntersecting;
sync();
});
resizer.observe(canvas);
watcher.observe(canvas);
document.addEventListener('visibilitychange', sync);
reduce.addEventListener('change', sync);
resize();
return () => {
stop();
resizer.disconnect();
watcher.disconnect();
document.removeEventListener('visibilitychange', sync);
reduce.removeEventListener('change', sync);
};
}
mount(document.querySelector('[data-ld-part="fx-motion"]'));
</script>
No remixes yet
Real fileA part inside a file (press to go to its lines)
Loading…
Address:ludion.ai/p/fx-motion/code/part.css · 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