Animation Lottie — Animations Programmatiques Basées sur JSON
Créez des logos animés, des icônes et des micro-interactions sous forme de fichiers Lottie JSON légers. Pas besoin d'After Effects — construisez des animations entièrement en code.
Aperçu
- Format : Lottie JSON (standard ouvert)
- Dépôt du lecteur : github.com/LottieFiles/lottie-player
- Dépôt de l'éditeur : github.com/marciogranzotto/lottie-tools (éditeur web open source)
- Licence : MIT
- Installation :
npm install lottie-webounpm install @lottiefiles/lottie-player
Qu'est-ce que Lottie ?
Lottie est un format d'animation basé sur JSON. Les animations sont décrites comme des propriétés avec images clés dans un fichier JSON structuré. Elles s'affichent à n'importe quelle résolution (vectorielles), sont très petites en taille de fichier et jouent nativement sur le web, iOS, Android et React Native.
Structure JSON Lottie
{
"v": "5.7.1", // Version Lottie
"fr": 30, // Fréquence d'images
"ip": 0, // Point d'entrée (image de début)
"op": 60, // Point de sortie (image de fin) — 2 secondes à 30 ips
"w": 400, // Largeur
"h": 400, // Hauteur
"assets": [], // Ressources externes (images, précompositions)
"layers": [ // Calques d'animation (de bas en haut)
{
"ty": 4, // Calque de forme
"nm": "Cercle", // Nom du calque
"ip": 0,
"op": 60,
"st": 0, // Temps de début
"ks": { // Propriétés de transformation
"o": { "a": 0, "k": 100 }, // Opacité (statique)
"r": { "a": 0, "k": 0 }, // Rotation
"p": { // Position (animée)
"a": 1, // a=1 signifie animé
"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] } // Échelle
},
"shapes": [...] // Définitions de formes
}
]
}
Types de Calques
| ty | Type | Description |
|---|---|---|
| 0 | Précomposition | Composition imbriquée |
| 1 | Solide | Calque de couleur unie |
| 2 | Image | Calque de ressource image |
| 3 | Nul | Parent de transformation vide |
| 4 | Forme | Formes vectorielles (le plus courant) |
| 5 | Texte | Calque de texte |
Types de Formes
| ty | Forme |
|---|---|
| "rc" | Rectangle |
| "el" | Ellipse |
| "sr" | Étoile/Polygone |
| "sh" | Tracé (bezier) |
| "fl" | Remplissage |
| "st" | Contour |
| "gf" | Remplissage dégradé |
| "gs" | Contour dégradé |
| "tr" | Transformation |
| "gr" | Groupe |
Construire des Animations en Code
Cercle Simple avec Fondu d'Entrée
{
"v": "5.7.1",
"fr": 30,
"ip": 0,
"op": 30,
"w": 200,
"h": 200,
"layers": [{
"ty": 4,
"nm": "cercle",
"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]}}
]
}
]
}]
}
Accélération des Images Clés
// Accélération entrée-sortie (lisse)
"i": {"x": [0.42], "y": [1]},
"o": {"x": [0.58], "y": [0]}
// Accélération sortie (décélération)
"i": {"x": [0.0], "y": [1]},
"o": {"x": [0.6], "y": [0]}
// Accélération entrée (accélération)
"i": {"x": [0.4], "y": [1]},
"o": {"x": [1.0], "y": [0]}
// Linéaire
"i": {"x": [1], "y": [1]},
"o": {"x": [0], "y": [0]}
Génération Programmatique avec 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,
};
}
// Générer et sauvegarder
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));
Jouer Lottie sur le Web
<!-- Via 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>
// Via npm
import lottie from "lottie-web";
const anim = lottie.loadAnimation({
container: document.getElementById("lottie"),
renderer: "svg",
loop: true,
autoplay: true,
animationData: require("./animation.json"),
});
Utiliser Lottie dans Remotion
import { Lottie } from "@remotion/lottie";
import animationData from "./animation.json";
export const MyScene: React.FC = () => {
return <Lottie animationData={animationData} />;
};
Installation : npm install @remotion/lottie
Bonnes Pratiques
- Restez simple — Moins de calques = fichier plus petit, meilleures performances
- Utilisez des calques de forme plutôt que des calques d'image quand c'est possible (vecteur = net à n'importe quelle taille)
- Accélération des images clés — N'utilisez jamais d'accélération linéaire pour un mouvement organique
- 30 ips est la norme pour les animations Lottie sur le web
- Moins de 2 secondes pour les micro-interactions, 3-5 secondes pour les logos
- Testez avec lottie-player — Aperçu avant intégration
- Optimisez — Supprimez les propriétés inutilisées, minimisez la précision des nombres
Source de la Compétence Agent
- Wiggle (compétence d'animation de logo) : github.com/talknerdytome-labs/wiggle-claude-skill
- Lottie Tools (éditeur) : github.com/marciogranzotto/lottie-tools
- OmniLottie (génération IA) : github.com/OpenVGLab/OmniLottie