← back to Model Arena
data/artifacts/15f8755f21c5/qwen3-14b.html
103 lines
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Animated Starfield Warp</title>
<style>
html, body {
margin: 0;
padding: 0;
overflow: hidden;
background: black;
height: 100%;
width: 100%;
cursor: none;
}
canvas {
display: block;
}
#controls {
position: absolute;
top: 10px;
left: 10px;
color: white;
font-family: sans-serif;
background: rgba(0,0,0,0.5);
padding: 10px;
border-radius: 5px;
}
input[type="range"] {
width: 200px;
}
</style>
</head>
<body>
<div id="controls">
<label for="speed">Warp Speed: <span id="speedValue">1</span></label>
<input type="range" id="speed" min="0.1" max="5" step="0.1" value="1">
</div>
<canvas id="starfield"></canvas>
<script>
const canvas = document.getElementById('starfield');
const ctx = canvas.getContext('2d');
const controls = document.getElementById('controls');
const speedSlider = document.getElementById('speed');
const speedValue = document.getElementById('speedValue');
let width, height;
let mouse = { x: 0, y: 0 };
let warpDirection = { x: 0, y: 0 };
let speed = parseFloat(speedSlider.value);
function resize() {
width = canvas.width = window.innerWidth;
height = canvas.height = window.innerHeight;
}
window.addEventListener('resize', resize);
resize();
window.addEventListener('mousemove', (e) => {
mouse.x = e.clientX;
mouse.y = e.clientY;
warpDirection.x = (mouse.x - width / 2) / (width / 2);
warpDirection.y = (mouse.y - height / 2) / (height / 2);
});
speedSlider.addEventListener('input', (e) => {
speed = parseFloat(e.target.value);
speedValue.textContent = speed.toFixed(1);
});
const stars = [];
for (let i = 0; i < 1000; i++) {
stars.push({
x: Math.random() * width,
y: Math.random() * height,
z: Math.random() * 100 + 50,
size: Math.random() * 1.5 + 0.5
});
}
function drawStars() {
ctx.clearRect(0, 0, width, height);
ctx.fillStyle = 'white';
ctx.beginPath();
for (let star of stars) {
const x = (star.x - width / 2 + star.z * warpDirection.x * 10) / star.z + width / 2;
const y = (star.y - height / 2 + star.z * warpDirection.y * 10) / star.z + height / 2;
ctx.moveTo(x, y);
ctx.arc(x, y, star.size / star.z * 10, 0, Math.PI * 2);
}
ctx.fill();
}
function animate() {
drawStars();
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>