← Demos
Web Pages · Hello World

Hydrate the Runner- Hello World

by William Mcclurg Aug 28, 2026 6 views 12.9 KB
Sandbox · hydrate-the-runner-hello-world · 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">
  <title>Hello World - Hydration Runner</title>
  <style>
    :root {
      --bg: #1a1a24;
      --card: #242438;
      --text: #ffffff;
      --water: #38bdf8;
      --fast: #4ade80;
      --normal: #ffffff;
      --exhausted: #ef4444;
    }

    body {
      margin: 0;
      padding: 20px;
      font-family: system-ui, -apple-system, sans-serif;
      background-color: var(--bg);
      color: var(--text);
      display: flex;
      flex-direction: column;
      align-items: center;
      min-height: 100vh;
      box-sizing: border-box;
    }

    h1 {
      margin: 10px 0 20px 0;
      font-size: 2.5rem;
      letter-spacing: -1px;
    }

    .container {
      display: flex;
      flex-direction: column;
      gap: 20px;
      width: 100%;
      max-width: 600px;
    }

    .track {
      background-color: var(--card);
      border-radius: 12px;
      height: 180px;
      position: relative;
      overflow: hidden;
      border: 2px solid #33334d;
    }

    .ground {
      position: absolute;
      bottom: 0;
      width: 100%;
      height: 24px;
      background: #33334d;
    }

    /* Runner Container */
    .runner-container {
      position: absolute;
      bottom: 24px;
      left: 20px;
      width: 60px;
      height: 75px;
      transition: left 0.1s linear;
    }

    .runner-svg {
      width: 100%;
      height: 100%;
      overflow: visible;
    }

    /* Rigged Animation Keyframes */
    .run-anim {
      animation-iteration-count: infinite;
      animation-timing-function: ease-in-out;
      animation-duration: 0.6s;
    }

    /* Vertical Body Bounce & Forward Lean */
    .body-rig {
      animation-name: body-bounce;
    }
    @keyframes body-bounce {
      0%, 50%, 100% { transform: translateY(0px) rotate(5deg); }
      25%, 75% { transform: translateY(-6px) rotate(7deg); }
    }

    /* Hip / Thigh Motions */
    .thigh-r { animation-name: thigh-r-anim; }
    .thigh-l { animation-name: thigh-l-anim; }

    @keyframes thigh-r-anim {
      0%   { transform: rotate(-38deg); }
      30%  { transform: rotate(10deg); }
      50%  { transform: rotate(42deg); }
      80%  { transform: rotate(10deg); }
      100% { transform: rotate(-38deg); }
    }
    @keyframes thigh-l-anim {
      0%   { transform: rotate(42deg); }
      30%  { transform: rotate(10deg); }
      50%  { transform: rotate(-38deg); }
      80%  { transform: rotate(10deg); }
      100% { transform: rotate(42deg); }
    }

    /* Knee / Calf Flexion */
    .calf-r { animation-name: calf-r-anim; }
    .calf-l { animation-name: calf-l-anim; }

    @keyframes calf-r-anim {
      0%   { transform: rotate(15deg); }
      25%  { transform: rotate(45deg); }
      50%  { transform: rotate(5deg); }
      75%  { transform: rotate(85deg); }
      100% { transform: rotate(15deg); }
    }
    @keyframes calf-l-anim {
      0%   { transform: rotate(5deg); }
      25%  { transform: rotate(85deg); }
      50%  { transform: rotate(15deg); }
      75%  { transform: rotate(45deg); }
      100% { transform: rotate(5deg); }
    }

    /* Shoulder / Arm Motion */
    .arm-r { animation-name: arm-r-anim; }
    .arm-l { animation-name: arm-l-anim; }

    @keyframes arm-r-anim {
      0%   { transform: rotate(38deg); }
      50%  { transform: rotate(-42deg); }
      100% { transform: rotate(38deg); }
    }
    @keyframes arm-l-anim {
      0%   { transform: rotate(-42deg); }
      50%  { transform: rotate(38deg); }
      100% { transform: rotate(-42deg); }
    }

    /* Forearm / Elbow Bend */
    .forearm-r { animation-name: forearm-r-anim; }
    .forearm-l { animation-name: forearm-l-anim; }

    @keyframes forearm-r-anim {
      0%   { transform: rotate(-20deg); }
      50%  { transform: rotate(-70deg); }
      100% { transform: rotate(-20deg); }
    }
    @keyframes forearm-l-anim {
      0%   { transform: rotate(-70deg); }
      50%  { transform: rotate(-20deg); }
      100% { transform: rotate(-70deg); }
    }

    /* Dashboard UI */
    .dashboard {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 20px;
    }

    .card {
      background-color: var(--card);
      border-radius: 12px;
      padding: 20px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      border: 2px solid #33334d;
    }

    .bottle-wrapper {
      position: relative;
      cursor: pointer;
      user-select: none;
      transition: transform 0.1s ease;
    }

    .bottle-wrapper:active {
      transform: scale(0.95);
    }

    .bottle-svg {
      width: 80px;
      height: 160px;
    }

    .water-level {
      transition: height 0.3s ease, y 0.3s ease, fill 0.3s ease;
    }

    button {
      margin-top: 15px;
      background-color: var(--water);
      color: #0f172a;
      border: none;
      padding: 10px 18px;
      border-radius: 8px;
      font-weight: bold;
      cursor: pointer;
      transition: background 0.2s;
    }

    button:hover {
      filter: brightness(1.1);
    }

    .stats {
      font-size: 0.95rem;
      line-height: 1.6;
      width: 100%;
    }

    .stat-row {
      display: flex;
      justify-content: space-between;
      margin-bottom: 8px;
    }
  </style>
</head>
<body>

  <h1>Hello World</h1>

  <div class="container">
    <!-- Track Scene -->
    <div class="track">
      <div class="runner-container" id="runner">
        <svg class="runner-svg" viewBox="0 0 60 75">
          <!-- Main Rigid Body Group -->
          <g class="body-rig run-anim">
            
            <!-- Hips / Leg System -->
            <g transform="translate(30, 36)">
              <!-- Left Leg (Far Side Shading) -->
              <g class="thigh-l run-anim">
                <line x1="0" y1="0" x2="0" y2="16" stroke="#64748b" stroke-width="3.5" stroke-linecap="round" />
                <g transform="translate(0, 16)">
                  <g class="calf-l run-anim">
                    <line x1="0" y1="0" x2="0" y2="16" stroke="#64748b" stroke-width="3.5" stroke-linecap="round" />
                  </g>
                </g>
              </g>

              <!-- Right Leg (Near Side Bright) -->
              <g class="thigh-r run-anim">
                <line x1="0" y1="0" x2="0" y2="16" stroke="#ffffff" stroke-width="4" stroke-linecap="round" />
                <g transform="translate(0, 16)">
                  <g class="calf-r run-anim">
                    <line x1="0" y1="0" x2="0" y2="16" stroke="#ffffff" stroke-width="4" stroke-linecap="round" />
                  </g>
                </g>
              </g>
            </g>

            <!-- Torso & Head -->
            <g transform="translate(30, 36)">
              <line x1="0" y1="0" x2="0" y2="-18" stroke="#ffffff" stroke-width="4" stroke-linecap="round" />
              <circle cx="0" cy="-25" r="6" fill="#ffffff" />

              <!-- Shoulders & Arm System -->
              <g transform="translate(0, -15)">
                <!-- Left Arm (Far Side Shading) -->
                <g class="arm-l run-anim">
                  <line x1="0" y1="0" x2="0" y2="11" stroke="#64748b" stroke-width="3" stroke-linecap="round" />
                  <g transform="translate(0, 11)">
                    <g class="forearm-l run-anim">
                      <line x1="0" y1="0" x2="0" y2="10" stroke="#64748b" stroke-width="3" stroke-linecap="round" />
                    </g>
                  </g>
                </g>

                <!-- Right Arm (Near Side Bright) -->
                <g class="arm-r run-anim">
                  <line x1="0" y1="0" x2="0" y2="11" stroke="#ffffff" stroke-width="3.5" stroke-linecap="round" />
                  <g transform="translate(0, 11)">
                    <g class="forearm-r run-anim">
                      <line x1="0" y1="0" x2="0" y2="10" stroke="#ffffff" stroke-width="3.5" stroke-linecap="round" />
                    </g>
                  </g>
                </g>
              </g>
            </g>

          </g>
        </svg>
      </div>
      <div class="ground"></div>
    </div>

    <!-- Interactive Dashboard -->
    <div class="dashboard">
      <div class="card">
        <div class="bottle-wrapper" id="bottle" title="Click to Drink Water (+25%)">
          <svg class="bottle-svg" viewBox="0 0 100 200">
            <rect x="35" y="10" width="30" height="15" rx="3" fill="#64748b" />
            <rect x="40" y="25" width="20" height="15" fill="#94a3b8" />
            <rect x="20" y="40" width="60" height="140" rx="15" fill="none" stroke="#94a3b8" stroke-width="6" />
            <defs>
              <clipPath id="bottle-clip">
                <rect x="23" y="43" width="54" height="134" rx="12" />
              </clipPath>
            </defs>
            <rect id="water" class="water-level" x="20" y="40" width="60" height="140" fill="#38bdf8" clip-path="url(#bottle-clip)" />
          </svg>
        </div>
        <button id="refill-btn">Refill to 100%</button>
      </div>

      <div class="card">
        <div class="stats">
          <div class="stat-row">
            <span>Hydration:</span>
            <strong id="hydration-val">100%</strong>
          </div>
          <div class="stat-row">
            <span>State:</span>
            <strong id="speed-val">Fast</strong>
          </div>
          <div class="stat-row">
            <span>Distance:</span>
            <strong id="distance-val">0 m</strong>
          </div>
        </div>
        <p style="font-size: 0.8rem; opacity: 0.7; text-align: center; margin-top: 15px;">
          Click the bottle to drink (+25% hydration)!
        </p>
      </div>
    </div>
  </div>

  <script>
    let waterLevel = 100;
    let distance = 0;
    let runnerPosX = 20;

    const runner = document.getElementById('runner');
    const animatedElements = document.querySelectorAll('.run-anim');
    const waterRect = document.getElementById('water');
    const bottle = document.getElementById('bottle');
    const refillBtn = document.getElementById('refill-btn');
    const hydrationVal = document.getElementById('hydration-val');
    const speedVal = document.getElementById('speed-val');
    const distanceVal = document.getElementById('distance-val');

    function updateWaterDisplay() {
      const maxHeight = 140;
      const calculatedHeight = (waterLevel / 100) * maxHeight;
      const calculatedY = 40 + (maxHeight - calculatedHeight);

      waterRect.setAttribute('height', calculatedHeight);
      waterRect.setAttribute('y', calculatedY);
      hydrationVal.textContent = `${Math.round(waterLevel)}%`;

      // Change liquid color based on state
      if (waterLevel >= 80) {
        waterRect.setAttribute('fill', '#4ade80'); // Fast (Green)
      } else if (waterLevel >= 40) {
        waterRect.setAttribute('fill', '#38bdf8'); // Normal (Blue)
      } else {
        waterRect.setAttribute('fill', '#ef4444'); // Exhausted (Red)
      }
    }

    // Add +25% hydration when drinking from the bottle
    bottle.addEventListener('click', () => {
      waterLevel = Math.min(100, waterLevel + 25);
      updateWaterDisplay();
    });

    refillBtn.addEventListener('click', () => {
      waterLevel = 100;
      updateWaterDisplay();
    });

    function animate() {
      let currentSpeed;
      let stateLabel;
      let stateColor;

      // Hydration Speed Thresholds
      if (waterLevel >= 80) {
        currentSpeed = 3.0;
        stateLabel = "Fast";
        stateColor = "#4ade80";
      } else if (waterLevel >= 40) {
        currentSpeed = 1.5;
        stateLabel = "Normal";
        stateColor = "#ffffff";
      } else {
        currentSpeed = 0.5;
        stateLabel = "Exhausted";
        stateColor = "#ef4444";
      }

      // Synchronize limb animation speed to stride velocity
      const animDuration = (0.6 / (currentSpeed / 1.5)).toFixed(2);
      animatedElements.forEach(el => el.style.animationDuration = `${animDuration}s`);

      // Update position & distance
      runnerPosX += currentSpeed;
      distance += currentSpeed * 0.1;

      const trackWidth = document.querySelector('.track').clientWidth;
      if (runnerPosX > trackWidth - 40) {
        runnerPosX = -40;
      }

      // Drain hydration gradually over time
      if (waterLevel > 0) {
        waterLevel -= 0.05;
        if (waterLevel < 0) waterLevel = 0;
        updateWaterDisplay();
      }

      // Update UI elements
      runner.style.left = `${runnerPosX}px`;
      distanceVal.textContent = `${Math.floor(distance)} m`;
      speedVal.textContent = stateLabel;
      speedVal.style.color = stateColor;

      requestAnimationFrame(animate);
    }

    updateWaterDisplay();
    animate();
  </script>
</body>
</html>

Reaches out to

Nothing. This page is entirely self-contained and contacts no other website when it runs.

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 William Mcclurg. 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.