Rack Focus Shift
Shift focus between a near and a far subject at slow or fast speed to see how attention moves.
AI prompt
Rack focus shot, 4 seconds, shallow depth of field at f/1.8: in the foreground a woman's hand holds a ringing phone, sharp and detailed, while a man in the doorway behind her is soft and blurred. At two seconds the focus slowly shifts over 1.5 seconds to the man in the background, who becomes sharp while the hand and phone dissolve into soft blur, warm indoor light, static locked-off camera, cinematic realism, subtle film grain. Variation: a fast rack of half a second for a sudden realisation. Negative: camera zoom, camera shake, both subjects sharp, flickering focus, morphing faces.About this pattern
Definition
A rack focus changes the focus plane during a shot, moving sharpness from one subject to another. The viewer's attention follows the sharp subject.
When to use it
- Reveals information (a clue in the background), connects two subjects or marks a change in emotion without cutting.
- Slow racks feel thoughtful and tense; fast racks feel startled or comedic.
- It needs a shallow depth of field (wide aperture, longer lens) and subjects at clearly different distances.
What the controls do
- Focus on near, focus on far; speed switch slow or fast; Auto alternates every two seconds.
Motion & timing
- Blur transitions between sharp and 8px over 1.6s (slow) or 0.5s (fast) with ease-in-out.
- Reduced motion: focus switches instantly.
Tips & variations
- Works at any size, but blur radius should scale with the frame; avoid tiny subjects that vanish when blurred.
- State the speed in seconds in prompts.
Code of this live preview
<div class="bx"><div class="sc"><div class="o near" id="near" aria-hidden="true"><i></i></div><div class="o far" id="far" aria-hidden="true"><b></b></div></div>
<div class="row"><div class="pre" id="pre" role="group" aria-label="Focus"><button data-f="near" aria-pressed="true">Focus near</button><button data-f="far" aria-pressed="false">Focus far</button></div><label class="sw"><input id="fast" type="checkbox"> Fast</label></div><label class="sw"><input id="auto" type="checkbox"> Auto</label></div>:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
.bx{width:min(300px,100%);display:grid;gap:10px}
.sc{position:relative;height:140px;border-radius:12px;overflow:hidden;background:linear-gradient(#e9dfcc,#cdbf9f)}
.o{position:absolute;transition:filter var(--t,1.6s) ease-in-out}
.near{left:26px;bottom:-6px;width:90px;height:110px;border-radius:50% 50% 0 0;background:#b4583a}.near i{position:absolute;right:-4px;top:30px;width:26px;height:44px;border-radius:6px;background:#2a2a2a}
.far{right:34px;top:20px;width:46px;height:96px}.far b{display:block;width:26px;height:26px;margin:0 auto;border-radius:50%;background:#7b5a44}.far::after{content:"";display:block;width:46px;height:64px;margin-top:2px;border-radius:20px 20px 4px 4px;background:#3f5a7a}
.row{display:flex;justify-content:space-between;align-items:center;gap:8px}
.pre{display:flex;gap:5px}.pre button{height:28px;padding:0 12px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11.5px;cursor:pointer}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.sw{display:flex;gap:6px;align-items:center;font-size:12px;color:var(--muted)}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
@media (prefers-reduced-motion:reduce){.o{transition:none}}const $=id=>document.getElementById(id),near=$('near'),far=$('far'),fast=$('fast'),auto=$('auto'),bs=[...document.querySelectorAll('#pre button')];let f='near',tm=0;
function apply(){near.style.filter='blur('+(f==='near'?0:8)+'px)';far.style.filter='blur('+(f==='far'?0:8)+'px)';bs.forEach(b=>b.setAttribute('aria-pressed',String(b.dataset.f===f)));}
function speed(){document.querySelector('.sc').style.setProperty('--t',(fast.checked?.5:1.6)+'s');}
bs.forEach(b=>b.addEventListener('click',()=>{f=b.dataset.f;apply();}));fast.addEventListener('change',speed);
auto.addEventListener('change',()=>{clearInterval(tm);if(auto.checked)tm=setInterval(()=>{f=f==='near'?'far':'near';apply();},2200);});speed();apply();One complete HTML file. Save it and open it in a browser.
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Rack Focus Shift — demo</title>
<style>
:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
html,body{height:100%}body{background:var(--bg);color:var(--text);font:15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Inter,Roboto,sans-serif;-webkit-font-smoothing:antialiased}.stage{min-height:100%;display:grid;place-items:center;padding:24px}button,input,select,textarea{font-family:inherit}@media (prefers-reduced-motion:reduce){html{scroll-behavior:auto}}
.bx{width:min(300px,100%);display:grid;gap:10px}
.sc{position:relative;height:140px;border-radius:12px;overflow:hidden;background:linear-gradient(#e9dfcc,#cdbf9f)}
.o{position:absolute;transition:filter var(--t,1.6s) ease-in-out}
.near{left:26px;bottom:-6px;width:90px;height:110px;border-radius:50% 50% 0 0;background:#b4583a}.near i{position:absolute;right:-4px;top:30px;width:26px;height:44px;border-radius:6px;background:#2a2a2a}
.far{right:34px;top:20px;width:46px;height:96px}.far b{display:block;width:26px;height:26px;margin:0 auto;border-radius:50%;background:#7b5a44}.far::after{content:"";display:block;width:46px;height:64px;margin-top:2px;border-radius:20px 20px 4px 4px;background:#3f5a7a}
.row{display:flex;justify-content:space-between;align-items:center;gap:8px}
.pre{display:flex;gap:5px}.pre button{height:28px;padding:0 12px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11.5px;cursor:pointer}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.sw{display:flex;gap:6px;align-items:center;font-size:12px;color:var(--muted)}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
@media (prefers-reduced-motion:reduce){.o{transition:none}}
</style></head>
<body><div class="stage">
<div class="bx"><div class="sc"><div class="o near" id="near" aria-hidden="true"><i></i></div><div class="o far" id="far" aria-hidden="true"><b></b></div></div>
<div class="row"><div class="pre" id="pre" role="group" aria-label="Focus"><button data-f="near" aria-pressed="true">Focus near</button><button data-f="far" aria-pressed="false">Focus far</button></div><label class="sw"><input id="fast" type="checkbox"> Fast</label></div><label class="sw"><input id="auto" type="checkbox"> Auto</label></div>
</div>
<script>
const $=id=>document.getElementById(id),near=$('near'),far=$('far'),fast=$('fast'),auto=$('auto'),bs=[...document.querySelectorAll('#pre button')];let f='near',tm=0;
function apply(){near.style.filter='blur('+(f==='near'?0:8)+'px)';far.style.filter='blur('+(f==='far'?0:8)+'px)';bs.forEach(b=>b.setAttribute('aria-pressed',String(b.dataset.f===f)));}
function speed(){document.querySelector('.sc').style.setProperty('--t',(fast.checked?.5:1.6)+'s');}
bs.forEach(b=>b.addEventListener('click',()=>{f=b.dataset.f;apply();}));fast.addEventListener('change',speed);
auto.addEventListener('change',()=>{clearInterval(tm);if(auto.checked)tm=setInterval(()=>{f=f==='near'?'far':'near';apply();},2200);});speed();apply();
</script>
</body></html>