|
| 1 | +<!-- |
| 2 | + Camcorder HUD |
| 3 | +
|
| 4 | + Paste inside a positioned composition stage and edit the displayed date, |
| 5 | + time, mode, and counter start. The registered timeline advances the counter |
| 6 | + and REC blink from composition time, so play, scrub, and render agree. |
| 7 | +
|
| 8 | + CSS variables: |
| 9 | + - --hf-camcorder-color (default #fff) |
| 10 | + - --hf-camcorder-accent (default #f12c2c) |
| 11 | + - --hf-camcorder-inset (default 5vmin) |
| 12 | + - --hf-camcorder-font-size (default 3.7vmin) |
| 13 | + - --hf-camcorder-z-index (default 90) |
| 14 | +--> |
| 15 | + |
| 16 | +<div id="ch-hud" data-hf-counter-start="0" aria-hidden="true"> |
| 17 | + <div class="ch-corner ch-record"><span class="ch-record-dot"></span><span>REC</span></div> |
| 18 | + <div class="ch-corner ch-battery"></div> |
| 19 | + <div class="ch-corner ch-date">JUL 20 2026<br />12:42 PM</div> |
| 20 | + <div class="ch-corner ch-counter"> |
| 21 | + <span class="ch-mode">SP · 16:9</span><span class="ch-counter-value">00:00:00</span> |
| 22 | + </div> |
| 23 | +</div> |
| 24 | + |
| 25 | +<style> |
| 26 | + #ch-hud { |
| 27 | + --hf-camcorder-color: #fff; |
| 28 | + --hf-camcorder-accent: #f12c2c; |
| 29 | + --hf-camcorder-inset: 5vmin; |
| 30 | + --hf-camcorder-font-size: 3.7vmin; |
| 31 | + --hf-camcorder-z-index: 90; |
| 32 | + position: absolute; |
| 33 | + inset: 0; |
| 34 | + z-index: var(--hf-camcorder-z-index); |
| 35 | + color: var(--hf-camcorder-color); |
| 36 | + font-family: monospace; |
| 37 | + font-size: var(--hf-camcorder-font-size); |
| 38 | + font-weight: 700; |
| 39 | + letter-spacing: 0; |
| 40 | + line-height: 1.25; |
| 41 | + pointer-events: none; |
| 42 | + -webkit-text-stroke: 0.12vmin rgb(0 0 0 / 92%); |
| 43 | + text-shadow: 0 0.2vmin 0.6vmin rgb(0 0 0 / 90%); |
| 44 | + } |
| 45 | + |
| 46 | + #ch-hud .ch-corner { |
| 47 | + position: absolute; |
| 48 | + } |
| 49 | + |
| 50 | + #ch-hud .ch-record { |
| 51 | + top: var(--hf-camcorder-inset); |
| 52 | + left: var(--hf-camcorder-inset); |
| 53 | + display: flex; |
| 54 | + align-items: center; |
| 55 | + gap: 1.8vmin; |
| 56 | + } |
| 57 | + |
| 58 | + #ch-hud .ch-record-dot { |
| 59 | + width: 2.2vmin; |
| 60 | + height: 2.2vmin; |
| 61 | + border-radius: 50%; |
| 62 | + background: var(--hf-camcorder-accent); |
| 63 | + box-shadow: 0 0 0.9vmin color-mix(in srgb, var(--hf-camcorder-accent) 55%, transparent); |
| 64 | + } |
| 65 | + |
| 66 | + #ch-hud .ch-battery { |
| 67 | + top: var(--hf-camcorder-inset); |
| 68 | + right: var(--hf-camcorder-inset); |
| 69 | + width: 7vmin; |
| 70 | + height: 3.5vmin; |
| 71 | + border: 0.35vmin solid currentcolor; |
| 72 | + } |
| 73 | + |
| 74 | + #ch-hud .ch-battery::before { |
| 75 | + position: absolute; |
| 76 | + top: 0.7vmin; |
| 77 | + left: 0.7vmin; |
| 78 | + width: 4.7vmin; |
| 79 | + height: 1.4vmin; |
| 80 | + background: currentcolor; |
| 81 | + content: ""; |
| 82 | + } |
| 83 | + |
| 84 | + #ch-hud .ch-battery::after { |
| 85 | + position: absolute; |
| 86 | + top: 0.7vmin; |
| 87 | + right: -1vmin; |
| 88 | + width: 0.7vmin; |
| 89 | + height: 1.4vmin; |
| 90 | + background: currentcolor; |
| 91 | + content: ""; |
| 92 | + } |
| 93 | + |
| 94 | + #ch-hud .ch-date { |
| 95 | + bottom: var(--hf-camcorder-inset); |
| 96 | + left: var(--hf-camcorder-inset); |
| 97 | + } |
| 98 | + |
| 99 | + #ch-hud .ch-counter { |
| 100 | + right: var(--hf-camcorder-inset); |
| 101 | + bottom: var(--hf-camcorder-inset); |
| 102 | + text-align: right; |
| 103 | + } |
| 104 | + |
| 105 | + #ch-hud .ch-mode { |
| 106 | + display: block; |
| 107 | + margin-bottom: 0.7vmin; |
| 108 | + font-size: 2.6vmin; |
| 109 | + } |
| 110 | +</style> |
| 111 | + |
| 112 | +<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script> |
| 113 | +<script> |
| 114 | + (function () { |
| 115 | + window.__timelines = window.__timelines || {}; |
| 116 | + |
| 117 | + var hud = document.getElementById("ch-hud"); |
| 118 | + var counter = hud && hud.querySelector(".ch-counter-value"); |
| 119 | + var recordDot = hud && hud.querySelector(".ch-record-dot"); |
| 120 | + if (!hud || !counter || !recordDot) return; |
| 121 | + |
| 122 | + var host = hud.closest("[data-composition-id]"); |
| 123 | + var duration = Number(host && host.getAttribute("data-duration")) || 10; |
| 124 | + var counterStart = Number(hud.getAttribute("data-hf-counter-start")) || 0; |
| 125 | + var state = { seconds: 0 }; |
| 126 | + |
| 127 | + function formatCounter(value) { |
| 128 | + var seconds = Math.max(0, Math.floor(value)); |
| 129 | + var hours = Math.floor(seconds / 3600); |
| 130 | + var minutes = Math.floor((seconds % 3600) / 60); |
| 131 | + var remainder = seconds % 60; |
| 132 | + return [hours, minutes, remainder] |
| 133 | + .map(function (part) { |
| 134 | + return String(part).padStart(2, "0"); |
| 135 | + }) |
| 136 | + .join(":"); |
| 137 | + } |
| 138 | + |
| 139 | + function updateHud() { |
| 140 | + counter.textContent = formatCounter(counterStart + state.seconds); |
| 141 | + recordDot.style.opacity = Math.floor(state.seconds / 0.55) % 2 === 0 ? "1" : "0.25"; |
| 142 | + } |
| 143 | + |
| 144 | + var tl = gsap.timeline({ paused: true }); |
| 145 | + tl.to(state, { seconds: duration, duration: duration, ease: "none", onUpdate: updateHud }, 0); |
| 146 | + updateHud(); |
| 147 | + tl.seek(0); |
| 148 | + window.__timelines["camcorder-hud"] = tl; |
| 149 | + })(); |
| 150 | +</script> |
0 commit comments