# 돌리 줌 (Dolly zoom)

카메라가 부두 표지판에서 멀어지면 렌즈의 초점 거리도 길어집니다. 화면 속 표지판의 크기는 그대로이고 뒤쪽 등대가 커집니다.

## 체험 방법

‘가까이’와 ‘멀리’를 번갈아 누르고 표지판의 높이와 오른쪽 등대의 크기를 비교하세요.

## 재현 기준

표지판까지의 거리를 3~12m로 바꾸면 초점 거리가 17.5~70mm로 변합니다. 레일은 0.1m 단위이고 동작 줄이기에서는 버튼을 누른 즉시 새 구도를 표시합니다.

## 기기별 조작

- PC · 레일에 초점을 두고 좌우 방향키로 0.1m씩 이동하세요. Home·End 또는 두 버튼으로 끝점을 비교할 수 있습니다.
- iOS · 레일을 손가락으로 밀거나 ‘가까이’와 ‘멀리’를 번갈아 탭하세요.
- Android · 레일을 손가락으로 밀거나 ‘가까이’와 ‘멀리’를 번갈아 탭하세요.

## 적용할 때

영화의 공간감을 설계하거나 카메라 위치와 초점 거리의 관계를 설명할 때 씁니다.

## 그대로 보낼 요청

> 카메라를 앞뒤로 옮길 때 피사체까지의 거리와 렌즈 초점 거리를 같은 비율로 바꿔줘. 전경 표지판의 크기를 유지하고 후경은 깊이에 맞춰 투영해줘.

## 참고한 동작

[Unity · Dolly Zoom](https://docs.unity3d.com/560/Documentation/Manual/DollyZoom.html)

## 독립 실행 코드

아래 전체 코드를 HTML로 저장해 브라우저에서 엽니다.

```html
<!doctype html>
<html lang="ko" data-motion-locales="inline">
<head><script>if(new URLSearchParams(location.search).get('reduce')==='1')document.documentElement.classList.add('motion-reduced');</script><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>항구의 돌리 줌 · MotionLab</title>
<style>
*{box-sizing:border-box} :root{font:15px/1.45 system-ui,sans-serif;color:#272e32;background:#f1e9da;color-scheme:light}body{margin:0;min-height:100svh;padding:clamp(10px,2.5vw,25px);display:grid;align-items:center}main{width:min(100%,720px);margin:0 auto}
header{display:flex;align-items:end;justify-content:space-between;gap:8px;flex-wrap:wrap;margin-bottom:9px}h1{font:700 clamp(20px,4vw,30px)/1.12 Georgia,serif;margin:0;letter-spacing:-.025em}.tag{color:#485952;font-size:12px;font-weight:650}
.camera{border:1px solid #364b49;background:#263c3f;color:#f7f0db;border-radius:8px;overflow:hidden}svg{display:block;width:100%;height:auto}.readouts{display:flex;flex-wrap:wrap;justify-content:space-between;gap:8px;padding:6px 12px;font:600 12px/1.45 system-ui,sans-serif;font-variant-numeric:tabular-nums}
.controls{display:grid;grid-template-columns:auto minmax(90px,1fr) auto;gap:8px;align-items:center;margin-top:11px}input{width:100%;accent-color:#80552f;min-height:32px}button{cursor:pointer;border:1px solid #ab9f84;background:#fffbf0;color:#352f29;font:650 13px/1.25 system-ui,sans-serif;padding:7px 12px;border-radius:20px;min-height:38px}button:focus-visible,input:focus-visible{outline:3px solid #196a77;outline-offset:3px}
p{margin:8px 0 0;font-size:13px;color:#3c4c49}label{display:block;margin-top:11px;font-weight:700;font-size:13px}.controls{margin-top:2px}@media(max-width:360px){button{font-size:12px;padding:6px 8px}.readouts{padding:5px 8px;gap:2px}}
@media(min-width:600px) and (max-height:560px){body{padding:8px 16px}main{width:min(100%,640px)}}
</style></head><body><main>
<header><h1 data-t="title"></h1><span class="tag" data-t="tech"></span></header>
<div class="camera"><svg id="scene" viewBox="0 0 520 230" role="img" aria-labelledby="photoTitle"><title id="photoTitle" data-t="photo"></title>
<defs><linearGradient id="sky" x2="0" y2="1"><stop stop-color="#7aabb4"/><stop offset="1" stop-color="#f8c89b"/></linearGradient><linearGradient id="water" x2="0" y2="1"><stop stop-color="#92b6b1"/><stop offset="1" stop-color="#3f747a"/></linearGradient><pattern id="grain" width="19" height="15" patternUnits="userSpaceOnUse"><path d="M3 9h2m8-6h1" stroke="#e0ece1" stroke-width=".7"/></pattern></defs>
<rect width="520" height="136" fill="url(#sky)"/><path fill="#a1b3ac" d="M0 115l46-18 26 4 29-15 40 15 51-17 27 7 43-17 44 13 24-4 37 17 34-13 40 16 39-9 40 9v32H0z"/>
<path fill="#788e86" d="M0 115l57-8 33 4 47-8 44 5 42-10 35 9 52-12 39 12 37-3 42 7 28-8 64 10v16H0z"/>
<rect y="119" width="520" height="111" fill="url(#water)"/><rect y="120" width="520" height="110" fill="url(#grain)" opacity=".65"/>
<g id="far-view"><path d="M-46 0q12-10 23-6l8-12 27 2 11 6 15-1 21 11z" fill="#607578"/><path d="M-10-8l3-44h11l5 44z" fill="#f0e9cc"/><path d="M-9-19l.6-8h14l1.4 8z" fill="#99583e"/><path d="M-9-52V-63H6v11z" fill="#344a50"/><path d="M-12-63l10-8 12 8z" fill="#ad664d"/><path d="M-4-60v6m5-6v6" stroke="#f5d395" stroke-width="2"/></g>
<g id="pier"></g><g id="subject"><path d="M-4-45h8v64h-8z" fill="#625348"/><path d="M-16 18h32l4 4h-40z" fill="#3b3936"/><path d="M0-85l23 29-23 29-23-29z" fill="#e4ad61" stroke="#463d35" stroke-width="2"/><path d="M0-78l17 22L0-34l-17-22z" fill="none" stroke="#83543c"/><path d="M0-68l8 12-8 12-8-12z" fill="#704438"/></g>
<path d="M12 24V11h18m460 0h18v13M12 206v13h18m460 0h18v-13" fill="none" stroke="#fff9dd" stroke-width="1.4"/>
</svg><div class="readouts" aria-hidden="true"><span><span data-t="dist"></span> <b id="distance"></b></span><span><span data-t="lens"></span> <b id="focal"></b></span></div></div>
<label for="rail" data-t="rail"></label><div class="controls"><button id="near" data-t="near"></button><input id="rail" type="range" min="30" max="120" step="1" value="60"><button id="far" data-t="far"></button></div>
<p data-t="help"></p></main><script>
const words={
 ko:{title:"부두의 거리감",tech:"돌리 줌",photo:"부두의 노란 표지판과 바다 건너 등대",dist:"카메라 거리",lens:"초점 거리",rail:"카메라 레일",near:"가까이",far:"멀리",help:"레일을 움직이며 표지판과 뒤쪽 등대의 크기를 비교하세요."},
 en:{title:"Along the pier",tech:"Dolly zoom",photo:"A yellow pier marker and a distant lighthouse",dist:"Camera distance",lens:"Focal length",rail:"Camera rail",near:"Move closer",far:"Move away",help:"Move the camera along the rail. Compare the size of the marker and the lighthouse behind it."},
 es:{title:"Perspectiva del muelle",tech:"Dolly zoom",photo:"Señal amarilla en el muelle y faro al fondo",dist:"Distancia",lens:"Distancia focal",rail:"Riel de cámara",near:"Acercar",far:"Alejar",help:"Desplaza la cámara por el riel y compara el tamaño de la señal con el del faro."},
 "zh-Hans":{title:"码头的纵深",tech:"滑动变焦",photo:"码头上的黄色标志与远处的灯塔",dist:"相机距离",lens:"焦距",rail:"相机轨道",near:"靠近",far:"后退",help:"沿轨道移动相机，比较标志和后方灯塔的大小。"}
};
const query=new URLSearchParams(location.search),lang=query.get('lang')||document.documentElement.lang||'ko',t=words[lang]||words.ko;
document.documentElement.lang=words[lang]?lang:'ko';document.title=t.title+' · MotionLab';
for(const node of document.querySelectorAll('[data-t]')) node.textContent=t[node.dataset.t];
const byId=id=>document.getElementById(id), rail=byId('rail'),pier=byId('pier'),media=matchMedia('(prefers-reduced-motion: reduce)');
const smallMotion=()=>query.get('reduce')==='1'||document.documentElement.classList.contains('motion-reduced')||media.matches;
let distance=6,frame=0;
// Fixed sensor and subject framing: focal length / subject distance is constant.
function point(x,y,z){const scale=distance/(distance+z);return [260+x*scale,119+y*scale];}
function place(id,x,y,z){const [px,py]=point(x,y,z);byId(id).setAttribute('transform','translate('+px+' '+py+') scale('+distance/(distance+z)+')');}
function polygon(points,color){return '<polygon fill="'+color+'" points="'+points.map(p=>point(...p).join(',')).join(' ')+'"/>';}
function render(value){
 distance=value;rail.value=Math.round(value*10);
 const focal=35*distance/6;
 byId('distance').textContent=distance.toFixed(1)+' m';byId('focal').textContent=focal.toFixed(1)+' mm';
 rail.setAttribute('aria-valuetext',distance.toFixed(1)+' m · '+focal.toFixed(1)+' mm');
 place('subject',0,59,0);place('far-view',220,8,11);
 let board=polygon([[-61,62,-2.4],[61,62,-2.4],[61,62,14],[-61,62,14]],'#b69065');
 for(let z=13.5;z>-2.4;z-=.57){board+=polygon([[-61,62,z],[61,62,z],[61,62,z-.035],[-61,62,z-.035]],'#805e49');}
 for(let z=12;z>=0;z-=3)for(const x of [-65,65]){
   board+=polygon([[x-2.7,62,z],[x+2.7,62,z],[x+2.7,24,z],[x-2.7,24,z]],'#5d5146');
   board+=polygon([[x-3.4,28,z],[x+3.4,28,z],[x+3.4,23,z],[x-3.4,23,z]],'#dfc5a0');
 }
 pier.innerHTML=board;byId('scene').dataset.distance=distance.toFixed(2);
}
function move(to){
 cancelAnimationFrame(frame);
 if(smallMotion()){render(to);return;}
 const from=distance,start=performance.now();
 function tick(now){const t=Math.min(1,(now-start)/440);if(smallMotion()||t>=1){render(to);return;}render(from+(to-from)*t*t*(3-2*t));frame=requestAnimationFrame(tick);}
 frame=requestAnimationFrame(tick);
}
rail.addEventListener('input',()=>{cancelAnimationFrame(frame);render(Number(rail.value)/10);});
byId('near').onclick=()=>move(3);byId('far').onclick=()=>move(12);render(6);
</script></body></html>
```

