Lottie 애니메이션 — 프로그래매틱 JSON 기반 애니메이션
애니메이션 로고, 아이콘, 마이크로 인터랙션을 경량 Lottie JSON 파일로 생성합니다. After Effects 없이 코드로만 애니메이션을 제작할 수 있습니다.
개요
- 형식: Lottie JSON (오픈 표준)
- 플레이어 저장소: github.com/LottieFiles/lottie-player
- 편집기 저장소: github.com/marciogranzotto/lottie-tools (오픈 소스 웹 편집기)
- 라이선스: MIT
- 설치:
npm install lottie-web또는npm install @lottiefiles/lottie-player
Lottie란?
Lottie는 JSON 기반 애니메이션 형식입니다. 애니메이션은 구조화된 JSON 파일에 키프레임 속성으로 기술됩니다. 벡터 기반이므로 모든 해상도에서 렌더링되며, 파일 크기가 매우 작고 웹, iOS, Android, React Native에서 기본적으로 지원됩니다.
Lottie JSON 구조
{
"v": "5.7.1", // Lottie 버전
"fr": 30, // 프레임 레이트
"ip": 0, // 시작 프레임
"op": 60, // 종료 프레임 — 30fps에서 2초
"w": 400, // 너비
"h": 400, // 높이
"assets": [], // 외부 에셋 (이미지, 프리컴프)
"layers": [ // 애니메이션 레이어 (아래에서 위로)
{
"ty": 4, // 셰이프 레이어
"nm": "Circle", // 레이어 이름
"ip": 0,
"op": 60,
"st": 0, // 시작 시간
"ks": { // 변환 속성
"o": { "a": 0, "k": 100 }, // 불투명도 (정적)
"r": { "a": 0, "k": 0 }, // 회전
"p": { // 위치 (애니메이션 적용)
"a": 1, // a=1은 애니메이션 적용됨
"k": [
{ "t": 0, "s": [200, 300], "e": [200, 100], "i": {"x": 0.5, "y": 1}, "o": {"x": 0.5, "y": 0} },
{ "t": 30, "s": [200, 100] }
]
},
"s": { "a": 0, "k": [100, 100] } // 배율
},
"shapes": [...] // 셰이프 정의
}
]
}
레이어 유형
| ty | 유형 | 설명 |
|---|---|---|
| 0 | Precomp | 중첩 컴포지션 |
| 1 | Solid | 단색 레이어 |
| 2 | Image | 이미지 에셋 레이어 |
| 3 | Null | 빈 변환 부모 |
| 4 | Shape | 벡터 셰이프 (가장 일반적) |
| 5 | Text | 텍스트 레이어 |
셰이프 유형
| ty | 셰이프 |
|---|---|
| "rc" | 사각형 |
| "el" | 타원 |
| "sr" | 별/다각형 |
| "sh" | 패스 (베지어) |
| "fl" | 채우기 |
| "st" | 선 |
| "gf" | 그라데이션 채우기 |
| "gs" | 그라데이션 선 |
| "tr" | 변환 |
| "gr" | 그룹 |
코드로 애니메이션 만들기
간단한 페이드인 원
{
"v": "5.7.1",
"fr": 30,
"ip": 0,
"op": 30,
"w": 200,
"h": 200,
"layers": [{
"ty": 4,
"nm": "circle",
"ip": 0,
"op": 30,
"st": 0,
"ks": {
"o": {
"a": 1,
"k": [
{"t": 0, "s": [0], "e": [100], "i": {"x": [0.4], "y": [1]}, "o": {"x": [0.6], "y": [0]}},
{"t": 20, "s": [100]}
]
},
"r": {"a": 0, "k": 0},
"p": {"a": 0, "k": [100, 100]},
"s": {
"a": 1,
"k": [
{"t": 0, "s": [0, 0], "e": [100, 100], "i": {"x": [0.2, 0.2], "y": [1, 1]}, "o": {"x": [0.8, 0.8], "y": [0, 0]}},
{"t": 25, "s": [100, 100]}
]
}
},
"shapes": [
{
"ty": "gr",
"it": [
{"ty": "el", "p": {"a": 0, "k": [0, 0]}, "s": {"a": 0, "k": [80, 80]}},
{"ty": "fl", "c": {"a": 0, "k": [0.2, 0.5, 1, 1]}, "o": {"a": 0, "k": 100}},
{"ty": "tr", "p": {"a": 0, "k": [0, 0]}, "s": {"a": 0, "k": [100, 100]}}
]
}
]
}]
}
키프레임 이징
// 이즈 인-아웃 (부드럽게)
"i": {"x": [0.42], "y": [1]},
"o": {"x": [0.58], "y": [0]}
// 이즈 아웃 (감속)
"i": {"x": [0.0], "y": [1]},
"o": {"x": [0.6], "y": [0]}
// 이즈 인 (가속)
"i": {"x": [0.4], "y": [1]},
"o": {"x": [1.0], "y": [0]}
// 직선
"i": {"x": [1], "y": [1]},
"o": {"x": [0], "y": [0]}
JavaScript로 프로그래매틱 생성
function createLottieAnimation({ width, height, fps, durationFrames, layers }) {
return {
v: "5.7.1",
fr: fps,
ip: 0,
op: durationFrames,
w: width,
h: height,
assets: [],
layers,
};
}
function createShapeLayer({ name, startFrame, endFrame, shapes, transform }) {
return {
ty: 4,
nm: name,
ip: startFrame,
op: endFrame,
st: startFrame,
ks: transform,
shapes,
};
}
// 생성 후 저장
const animation = createLottieAnimation({
width: 400, height: 400, fps: 30, durationFrames: 60,
layers: [/* ... */],
});
const fs = require("fs");
fs.writeFileSync("animation.json", JSON.stringify(animation, null, 2));
웹에서 Lottie 재생
<!-- CDN 사용 -->
<script src="https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js"></script>
<lottie-player src="animation.json" background="transparent" speed="1" loop autoplay></lottie-player>
// npm 사용
import lottie from "lottie-web";
const anim = lottie.loadAnimation({
container: document.getElementById("lottie"),
renderer: "svg",
loop: true,
autoplay: true,
animationData: require("./animation.json"),
});
Remotion에서 Lottie 사용
import { Lottie } from "@remotion/lottie";
import animationData from "./animation.json";
export const MyScene: React.FC = () => {
return <Lottie animationData={animationData} />;
};
설치: npm install @remotion/lottie
모범 사례
- 간단하게 유지 — 레이어가 적을수록 파일 크기 작아지고 성능 향상
- 이미지 레이어보다 셰이프 레이어 사용 — 벡터는 모든 크기에서 선명함
- 키프레임 이징 적용 — 자연스러운 움직임을 위해 선형 이징은 피할 것
- 30fps가 웹 Lottie 애니메이션의 표준
- 마이크로 인터랙션은 2초 미만, 로고는 3-5초로 제한
- lottie-player로 테스트 — 임베드 전에 미리보기
- 최적화 — 사용하지 않는 속성 제거, 숫자 정밀도 최소화
에이전트 스킬 출처
- Wiggle (로고 애니메이션 스킬): github.com/talknerdytome-labs/wiggle-claude-skill
- Lottie Tools (편집기): github.com/marciogranzotto/lottie-tools
- OmniLottie (AI 생성): github.com/OpenVGLab/OmniLottie