← Demos
Web Pages · Hello World

Hello World across languages

by Juan Luis Jooss Aug 27, 2026 7 views 14.2 KB
Sandbox · hello-world-across-languages · no access to your account
View source — the whole page is this one file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>hello, world — a tactile toy</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&family=Space+Mono:wght@400;700&display=swap" rel="stylesheet">
<style>
  :root{
    --bg:#F1ECFF;
    --dot:#D8CDF4;
    --ink:#241A46;
    --ink-soft:#6B5E93;
    --pill:rgba(255,255,255,.72);
    --pill-brd:rgba(120,100,180,.28);
    --focus:#7B4DFF;
  }
  *{box-sizing:border-box}
  html,body{margin:0;height:100%}
  body{
    background:var(--bg);
    background-image:radial-gradient(var(--dot) 1.6px, transparent 1.6px);
    background-size:26px 26px;
    background-position:-13px -13px;
    color:var(--ink);
    font-family:"Space Mono",ui-monospace,monospace;
    overflow:hidden;
    -webkit-user-select:none;user-select:none;
    touch-action:none;
  }

  .eyebrow{
    position:fixed;top:22px;left:24px;z-index:5;
    font-size:12px;letter-spacing:.14em;text-transform:uppercase;
    color:var(--ink-soft);
  }
  .eyebrow b{color:var(--ink)}

  .stage{position:fixed;inset:0;z-index:1}
  .words{position:absolute;inset:0;display:flex;flex-wrap:wrap;
    align-content:center;justify-content:center;gap:10px 8px;
    padding:96px 20px 150px;opacity:0;transition:opacity .3s ease}
  .words.ready{opacity:1}

  /* physics tiles are absolutely positioned; measuring mode returns them to flow */
  .letter{
    position:absolute;left:0;top:0;
    width:var(--sz);height:var(--sz);
    display:grid;place-items:center;
    border-radius:22%;
    background:var(--c);
    color:#fff;
    font-family:"Fredoka",system-ui,sans-serif;
    font-weight:700;
    font-size:calc(var(--sz) * .58);
    line-height:1;
    box-shadow:0 8px 0 var(--shade), 0 14px 22px rgba(60,30,110,.20);
    cursor:grab;
    will-change:transform;
    transform:translate3d(0,0,0);
  }
  .letter.grab{cursor:grabbing;z-index:50;
    box-shadow:0 16px 0 var(--shade), 0 30px 44px rgba(60,30,110,.32)}
  .gap{position:relative;width:var(--gap-w);height:var(--sz)}

  .words.measuring .letter{position:relative;transform:none!important}
  .words.measuring .gap{position:relative}

  .bar{
    position:fixed;left:50%;bottom:22px;transform:translateX(-50%);z-index:6;
    display:flex;align-items:center;gap:6px;
    padding:8px;border-radius:999px;
    background:var(--pill);border:1px solid var(--pill-brd);
    backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);
    box-shadow:0 10px 30px rgba(60,30,110,.16);
    max-width:calc(100vw - 24px);
  }
  .lang{
    display:flex;flex-direction:column;justify-content:center;
    padding:2px 14px 2px 8px;min-width:118px;
  }
  .lang .k{font-size:9px;letter-spacing:.16em;text-transform:uppercase;color:var(--ink-soft)}
  .lang .v{font-size:14px;font-weight:700;color:var(--ink);white-space:nowrap}
  .btn{
    appearance:none;border:none;cursor:pointer;
    font-family:"Space Mono",monospace;font-weight:700;font-size:13px;
    color:var(--ink);background:#fff;
    padding:10px 14px;border-radius:999px;
    box-shadow:0 3px 0 rgba(120,100,180,.30);
    transition:transform .06s ease, box-shadow .06s ease, background .15s ease;
    white-space:nowrap;
  }
  .btn:hover{background:#FBFAFF}
  .btn:active{transform:translateY(3px);box-shadow:0 0 0 rgba(120,100,180,.30)}
  .btn.primary{background:var(--ink);color:#fff;box-shadow:0 3px 0 #120b2c}
  .btn.primary:active{box-shadow:0 0 0 #120b2c}
  .btn:focus-visible,.icon:focus-visible{outline:3px solid var(--focus);outline-offset:2px}
  .icon{width:40px;height:40px;padding:0;font-size:16px;display:grid;place-items:center}

  .hint{
    position:fixed;left:0;right:0;bottom:76px;z-index:4;text-align:center;
    font-size:11.5px;letter-spacing:.04em;color:var(--ink-soft);
    pointer-events:none;transition:opacity .5s ease;padding:0 16px;
  }

  @media (max-width:560px){
    .lang{min-width:96px;padding-left:6px}
    .btn{padding:9px 11px;font-size:12px}
    .txt-lang{display:none}
    .eyebrow{font-size:11px;left:16px;top:16px}
  }
</style>
</head>
<body>
  <div class="eyebrow"><b>hello, world</b> &nbsp;·&nbsp; grab a block</div>

  <div class="stage" id="stage">
    <div class="words" id="words" aria-label="Interactive greeting made of draggable blocks"></div>
  </div>

  <p class="hint" id="hint">drag a block and fling it · sweep your cursor through the letters · tap to pop</p>

  <div class="bar" role="group" aria-label="Controls">
    <div class="lang">
      <span class="k">saying hello in</span>
      <span class="v" id="langName">English</span>
    </div>
    <button class="btn primary" id="nextLang">next <span class="txt-lang">language</span> ↻</button>
    <button class="btn icon" id="shuffle" title="Shuffle colors" aria-label="Shuffle colors">🎨</button>
    <button class="btn icon" id="reset" title="Drop the blocks" aria-label="Drop the blocks again">⟳</button>
  </div>

<script>
(function(){
  "use strict";
  const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;

  const GREETINGS = [
    {name:"English",   text:"HELLO WORLD"},
    {name:"Spanish",   text:"HOLA MUNDO"},
    {name:"French",    text:"BONJOUR MONDE"},
    {name:"German",    text:"HALLO WELT"},
    {name:"Italian",   text:"CIAO MONDO"},
    {name:"Portuguese",text:"OLÁ MUNDO"},
    {name:"Swahili",   text:"HABARI DUNIA"},
    {name:"Hawaiian",  text:"ALOHA HONUA"},
  ];
  const PALETTE = ["#FF6392","#FFB23E","#2CD4A8","#38BDF8","#8B5CF6","#FF785A","#A3E635","#F472B6"];
  const shade = {
    "#FF6392":"#D8447173","#FFB23E":"#D98C1873","#2CD4A8":"#17A67F73","#38BDF8":"#1E93CC73",
    "#8B5CF6":"#6A3FCC73","#FF785A":"#D9563873","#A3E635":"#7CB61E73","#F472B6":"#CC4D9273"
  };

  const stage = document.getElementById('stage');
  const words = document.getElementById('words');
  const langName = document.getElementById('langName');
  const hint = document.getElementById('hint');

  let letters = [];      // physics tiles only
  let langIndex = 0;
  let colorOffset = 0;
  let tileSize = 84;

  function computeSize(){
    const w = window.innerWidth;
    tileSize = Math.max(46, Math.min(96, Math.round(w/12)));
    document.documentElement.style.setProperty('--sz', tileSize+'px');
    document.documentElement.style.setProperty('--gap-w', Math.round(tileSize*0.34)+'px');
  }

  // Build the DOM for the current greeting
  function build(){
    words.innerHTML = '';
    letters = [];
    const chars = GREETINGS[langIndex].text.split('');
    let ci = 0;
    chars.forEach(ch=>{
      if(ch === ' '){
        const g = document.createElement('span');
        g.className = 'gap';
        words.appendChild(g);
        return;
      }
      const color = PALETTE[(ci + colorOffset) % PALETTE.length];
      const el = document.createElement('span');
      el.className = 'letter';
      el.textContent = ch;
      el.style.setProperty('--c', color);
      el.style.setProperty('--shade', shade[color]);
      const tilt = (Math.random()*10 - 5);
      const L = {el, x:0,y:0, hx:0,hy:0, vx:0,vy:0, tilt, phase:Math.random()*Math.PI*2, grabbed:false, popT:0};
      el.addEventListener('pointerdown', e=>startDrag(e, L));
      words.appendChild(el);
      letters.push(L);
      ci++;
    });
    langName.textContent = GREETINGS[langIndex].name;
  }

  // Measure natural (flow) positions => home coordinates
  function layout(dropIn){
    words.classList.add('measuring');
    // force reflow
    void words.offsetWidth;
    const sr = stage.getBoundingClientRect();
    letters.forEach(L=>{
      const r = L.el.getBoundingClientRect();
      L.hx = r.left - sr.left;
      L.hy = r.top - sr.top;
    });
    words.classList.remove('measuring');
    letters.forEach(L=>{
      L.el.style.left = L.hx+'px';
      L.el.style.top  = L.hy+'px';
    });

    if(dropIn && !reduceMotion){
      letters.forEach(L=>{
        L.x = L.hx + (Math.random()*70-35);
        L.y = -100 - Math.random()*260;
        L.vx = (Math.random()*2-1)*2;
        L.vy = 0;
      });
    } else {
      letters.forEach(L=>{ L.x=L.hx; L.y=L.hy; L.vx=0; L.vy=0; });
    }
    words.classList.add('ready');
  }

  function relayout(dropIn){
    computeSize();
    layout(dropIn);
  }

  // ---- Pointer / dragging ----
  const pointer = {x:-9999, y:-9999, active:false};
  let drag = null, dragOff={x:0,y:0}, dragPrev={x:0,y:0}, downAt=0, downPos={x:0,y:0};

  function stagePoint(e){
    const sr = stage.getBoundingClientRect();
    return {x:e.clientX - sr.left, y:e.clientY - sr.top};
  }

  function startDrag(e, L){
    unlockAudio();
    e.preventDefault();
    const p = stagePoint(e);
    drag = L; L.grabbed = true; L.el.classList.add('grab');
    dragOff.x = p.x - L.x; dragOff.y = p.y - L.y;
    dragPrev.x = p.x; dragPrev.y = p.y;
    downAt = performance.now(); downPos = {x:e.clientX, y:e.clientY};
    dismissHint();
  }

  window.addEventListener('pointermove', e=>{
    const p = stagePoint(e);
    pointer.x = p.x; pointer.y = p.y; pointer.active = true;
    if(drag){
      drag.vx = p.x - dragPrev.x;
      drag.vy = p.y - dragPrev.y;
      drag.x = p.x - dragOff.x;
      drag.y = p.y - dragOff.y;
      dragPrev.x = p.x; dragPrev.y = p.y;
    }
  }, {passive:true});

  window.addEventListener('pointerup', e=>{
    if(drag){
      const dt = performance.now()-downAt;
      const moved = Math.hypot(e.clientX-downPos.x, e.clientY-downPos.y);
      if(dt < 220 && moved < 8){ pop(drag); }      // quick tap
      drag.el.classList.remove('grab');
      drag.grabbed = false;
      drag = null;
    }
  });
  window.addEventListener('pointercancel', ()=>{
    if(drag){ drag.el.classList.remove('grab'); drag.grabbed=false; drag=null; }
  });
  stage.addEventListener('pointerleave', ()=>{ pointer.active=false; pointer.x=-9999; pointer.y=-9999; });

  // ---- Physics ----
  const K = 0.055, FRICTION = 0.9, REST = 0.62, REPEL_R = 96, REPEL_F = 1.1;

  let last = performance.now();
  function tick(now){
    const dt = Math.min(2.2, (now-last)/16.67); last = now;
    const half = tileSize/2;
    const maxX = stage.clientWidth  - tileSize;
    const maxY = stage.clientHeight - tileSize;

    for(const L of letters){
      if(L.popT>0) L.popT = Math.max(0, L.popT - dt*0.09);

      if(!L.grabbed){
        // idle bob target
        let ty = L.hy;
        if(!reduceMotion) ty += Math.sin(now*0.0018 + L.phase)*3.2;
        L.vx += (L.hx - L.x) * K * dt;
        L.vy += (ty   - L.y) * K * dt;

        // cursor repulsion
        if(pointer.active){
          const cx = L.x + half, cy = L.y + half;
          const dx = cx - pointer.x, dy = cy - pointer.y;
          const d = Math.hypot(dx,dy);
          if(d < REPEL_R && d > 0.001){
            const f = (1 - d/REPEL_R) * REPEL_F * dt;
            L.vx += (dx/d) * f * 26;
            L.vy += (dy/d) * f * 26;
          }
        }

        L.vx *= FRICTION; L.vy *= FRICTION;
        L.x += L.vx * dt;  L.y += L.vy * dt;

        // walls
        if(L.x < 0){ L.x = 0; L.vx = -L.vx*REST; bump(Math.abs(L.vx)); }
        else if(L.x > maxX){ L.x = maxX; L.vx = -L.vx*REST; bump(Math.abs(L.vx)); }
        if(L.y < 0){ L.y = 0; L.vy = -L.vy*REST; bump(Math.abs(L.vy)); }
        else if(L.y > maxY){ L.y = maxY; L.vy = -L.vy*REST; bump(Math.abs(L.vy)); }
      }

      const dxh = L.x - L.hx, dyh = L.y - L.hy;
      const speed = Math.min(1, Math.hypot(L.vx,L.vy)/26);
      const lean = L.grabbed ? Math.max(-14,Math.min(14, L.vx*0.9)) : L.vx*0.6;
      const scale = 1 + L.popT*0.5 + (L.grabbed?0.06:0);
      const spin = L.popT*180;
      L.el.style.transform =
        `translate3d(${dxh}px,${dyh}px,0) rotate(${L.tilt+lean+spin*0.0}deg) scale(${scale})`;
      if(L.popT>0){
        L.el.style.transform =
          `translate3d(${dxh}px,${dyh}px,0) rotate(${L.tilt+lean+spin}deg) scale(${scale})`;
      }
    }
    requestAnimationFrame(tick);
  }

  function pop(L){
    L.popT = 1;
    L.vy -= 8; L.vx += (Math.random()*6-3);
    beep(300 + Math.random()*260, 0.16, 'triangle');
  }

  // ---- Audio ----
  let AC=null, unlocked=false, lastBump=0;
  function unlockAudio(){
    if(unlocked) return;
    try{
      AC = new (window.AudioContext||window.webkitAudioContext)();
      unlocked = true;
    }catch(e){ unlocked=true; }
  }
  function beep(freq, dur, type){
    if(!AC) return;
    const t = AC.currentTime;
    const o = AC.createOscillator(), g = AC.createGain();
    o.type = type||'sine'; o.frequency.value = freq;
    g.gain.setValueAtTime(0.0001, t);
    g.gain.exponentialRampToValueAtTime(0.22, t+0.008);
    g.gain.exponentialRampToValueAtTime(0.0001, t+dur);
    o.connect(g).connect(AC.destination);
    o.start(t); o.stop(t+dur+0.02);
  }
  function bump(v){
    if(!AC || v < 1.2) return;
    const now = performance.now();
    if(now - lastBump < 45) return;
    lastBump = now;
    beep(90 + Math.min(180, v*10), 0.09, 'sine');
  }

  // ---- Controls ----
  let hintGone = false;
  function dismissHint(){ if(hintGone) return; hintGone=true; hint.style.opacity=0; }

  document.getElementById('nextLang').addEventListener('click', ()=>{
    unlockAudio();
    langIndex = (langIndex+1) % GREETINGS.length;
    colorOffset = (colorOffset+3) % PALETTE.length;
    build(); relayout(true);
    beep(520,0.12,'triangle');
    dismissHint();
  });
  document.getElementById('shuffle').addEventListener('click', ()=>{
    unlockAudio();
    colorOffset = (colorOffset+1) % PALETTE.length;
    letters.forEach((L,i)=>{
      const c = PALETTE[(i+colorOffset)%PALETTE.length];
      L.el.style.setProperty('--c', c);
      L.el.style.setProperty('--shade', shade[c]);
    });
    beep(660,0.1,'triangle');
  });
  document.getElementById('reset').addEventListener('click', ()=>{
    unlockAudio();
    relayout(true);
    beep(440,0.12,'triangle');
  });

  let rz;
  window.addEventListener('resize', ()=>{
    clearTimeout(rz);
    rz = setTimeout(()=>relayout(false), 140);
  });

  // ---- Boot ----
  function boot(){
    computeSize();
    build();
    layout(true);
    requestAnimationFrame(tick);
    setTimeout(()=>{ if(!hintGone){ hint.style.opacity=0; } }, 8000);
  }
  if(document.fonts && document.fonts.ready){
    document.fonts.ready.then(boot);
    setTimeout(()=>{ if(!letters.length) boot(); }, 900); // fallback if fonts hang
  } else { boot(); }
})();
</script>
</body>
</html>

Reaches out to

Websites this page contacts when it runs — fonts, chart libraries, data. Found by reading its source.

  • fonts.googleapis.com
  • fonts.gstatic.com

Licence

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 Juan Luis Jooss. Licensed under the MIT License. Published on Globefin.

Provided as is, without warranty. Any external libraries it loads keep their own licences. Terms →

Sandbox

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.