Build a single html page that says hello word that has a baseball field and staduim and when you click it a ball goes into the crowd for a homerun.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello, World! Home Run</title>
<style>
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body {
background: #071b2b;
color: #fff;
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
main { position: relative; width: 100%; height: 100%; }
canvas {
display: block;
width: 100%;
height: 100%;
cursor: pointer;
outline: none;
}
canvas:focus-visible { outline: 4px solid #ffd166; outline-offset: -8px; }
.title {
position: absolute;
top: clamp(20px, 5vw, 54px);
left: 0;
right: 0;
text-align: center;
pointer-events: none;
text-shadow: 0 3px 12px #00111dcc;
}
h1 {
margin: 0;
font-size: clamp(2rem, 7vw, 5.5rem);
letter-spacing: .08em;
line-height: 1;
}
.subtitle {
margin-top: 12px;
color: #c8e9ee;
font-size: clamp(.85rem, 2vw, 1.1rem);
letter-spacing: .18em;
text-transform: uppercase;
}
.hint {
position: absolute;
bottom: 25px;
left: 50%;
transform: translateX(-50%);
padding: 11px 18px;
border: 1px solid #ffffff55;
border-radius: 999px;
background: #071b2bcc;
color: #f8f3df;
font-size: .9rem;
white-space: nowrap;
pointer-events: none;
}
.hit { animation: flash .55s ease-out; }
@keyframes flash {
0% { color: #ffd166; transform: scale(1.08); }
100% { color: white; transform: scale(1); }
}
</style>
</head>
<body>
<main>
<canvas id="stadium" tabindex="0" role="button" aria-label="Baseball stadium. Click or press Enter to hit a home run."></canvas>
<div class="title" id="title">
<h1>Hello, World!</h1>
<div class="subtitle">Take me out to the ball game</div>
</div>
<div class="hint">Click the stadium — or press Enter — to swing</div>
</main>
<script>
const canvas = document.getElementById("stadium");
const ctx = canvas.getContext("2d");
const title = document.getElementById("title");
let W, H, dpr, flight = null, flash = 0;
function resize() {
dpr = Math.min(devicePixelRatio || 1, 2);
W = innerWidth; H = innerHeight;
canvas.width = W * dpr; canvas.height = H * dpr;
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
}
addEventListener("resize", resize);
resize();
function draw() {
const horizon = H * .39;
const g = ctx.createLinearGradient(0, 0, 0, H);
g.addColorStop(0, "#123d59"); g.addColorStop(.43, "#2c7890"); g.addColorStop(1, "#071d2b");
ctx.fillStyle = g; ctx.fillRect(0, 0, W, H);
// Stadium lights and upper rim
ctx.fillStyle = "#071a2a";
ctx.beginPath(); ctx.ellipse(W/2, horizon + 22, W*.62, H*.22, 0, 0, Math.PI*2); ctx.fill();
ctx.fillStyle = "#173b4b";
ctx.beginPath(); ctx.ellipse(W/2, horizon + 28, W*.55, H*.17, 0, 0, Math.PI*2); ctx.fill();
// Crowd sections
const rows = Math.max(5, Math.floor(H / 75));
for (let r = 0; r < rows; r++) {
const y = horizon - 16 + r * 17;
for (let x = 18; x < W - 10; x += 18) {
const wobble = Math.sin(x * .07 + r) * 3;
ctx.fillStyle = ["#ef476f","#ffd166","#06d6a0","#8ecae6","#f7f3e3"][((x/18+r)%5)|0];
ctx.beginPath(); ctx.arc(x, y + wobble, 3.5, 0, Math.PI*2); ctx.fill();
}
}
// Scoreboard
const sw = Math.min(270, W*.42), sh = 62, sx = W/2-sw/2, sy = horizon-92;
ctx.fillStyle = "#102531"; ctx.fillRect(sx, sy, sw, sh);
ctx.strokeStyle = "#d7b967"; ctx.lineWidth = 3; ctx.strokeRect(sx, sy, sw, sh);
ctx.fillStyle = "#ffd166"; ctx.font = "bold 14px system-ui"; ctx.textAlign = "center";
ctx.fillText("HOME", sx+sw*.26, sy+22); ctx.fillText("GUEST", sx+sw*.74, sy+22);
ctx.font = "bold 25px system-ui"; ctx.fillText("1", sx+sw*.26, sy+49); ctx.fillText("0", sx+sw*.74, sy+49);
// Field
ctx.fillStyle = "#27754c";
ctx.beginPath();
ctx.moveTo(0, H); ctx.lineTo(W, H); ctx.lineTo(W*.78, horizon+25);
ctx.quadraticCurveTo(W/2, horizon-10, W*.22, horizon+25); ctx.closePath(); ctx.fill();
ctx.strokeStyle = "#dff2c5"; ctx.lineWidth = 3;
ctx.beginPath(); ctx.moveTo(W/2, H*.69); ctx.lineTo(W*.08, horizon+30); ctx.moveTo(W/2, H*.69); ctx.lineTo(W*.92, horizon+30); ctx.stroke();
// Infield diamond
const home = {x:W/2, y:H*.69}, third={x:W*.38,y:H*.59}, second={x:W/2,y:H*.48}, first={x:W*.62,y:H*.59};
ctx.fillStyle = "#c99a62"; ctx.beginPath();
ctx.moveTo(home.x,home.y); ctx.lineTo(third.x,third.y); ctx.lineTo(second.x,second.y);
ctx.lineTo(first.x,first.y); ctx.closePath(); ctx.fill();
ctx.strokeStyle = "#f5e4b8"; ctx.lineWidth = 2; ctx.stroke();
[home, third, second, first].forEach(p => {
ctx.fillStyle = "#fff9df"; ctx.fillRect(p.x-4,p.y-4,8,8);
});
// Bat and batter
ctx.strokeStyle = "#f4d6a0"; ctx.lineWidth = 5; ctx.lineCap = "round";
ctx.beginPath(); ctx.moveTo(home.x-18,home.y+13); ctx.lineTo(home.x-7,home.y-13); ctx.stroke();
ctx.strokeStyle = "#713f31"; ctx.lineWidth = 4;
ctx.beginPath(); ctx.moveTo(home.x-8,home.y-10); ctx.lineTo(home.x-34,home.y-29); ctx.stroke();
if (flight) drawBall(flight);
if (flash > 0) { ctx.fillStyle = `rgba(255,209,102,${flash*.12})`; ctx.fillRect(0,0,W,H); flash -= .035; }
requestAnimationFrame(draw);
}
function drawBall(f) {
const t = Math.min(1, (performance.now()-f.start)/f.duration);
const sx=W/2-34, sy=H*.60, ex=W*.78, ey=H*.23;
const x=sx+(ex-sx)*t, y=sy+(ey-sy)*t-Math.sin(Math.PI*t)*H*.20;
ctx.strokeStyle="rgba(255,255,255,.35)"; ctx.lineWidth=2;
ctx.beginPath(); ctx.moveTo(x-34,y+18); ctx.lineTo(x-5,y+3); ctx.stroke();
ctx.fillStyle="#fff8df"; ctx.beginPath(); ctx.arc(x,y, t> .8 ? 8 : 6,0,Math.PI*2); ctx.fill();
ctx.strokeStyle="#d84b4b"; ctx.lineWidth=1.5; ctx.beginPath();
ctx.arc(x,y, t> .8 ? 6 : 4, -.7, .7); ctx.stroke();
if(t===1) { flight=null; flash=1; title.classList.remove("hit"); void title.offsetWidth; title.classList.add("hit"); }
}
function homerun() {
flight = {start: performance.now(), duration: 1050};
flash = .5;
}
canvas.addEventListener("click", homerun);
canvas.addEventListener("keydown", e => {
if (e.key === "Enter" || e.key === " ") { e.preventDefault(); homerun(); }
});
draw();
</script>
</body>
</html>
Nothing. This page is entirely self-contained and contacts no other website when it runs.
Published on Globefin under the MIT License. You may copy, change, and reuse this page, including commercially — just keep the notice below with it.
Copyright © 2026 Luke Blue. Licensed under the MIT License. Published on Globefin.
Provided as is, without warranty. Any external libraries it loads keep their own licences. Terms →
Scripts run, but the demo has its own throwaway origin. It can't read your session or cookies, can't reach the page around it, and can't navigate your tab. Don't enter real passwords or personal data into any demo.