From 5d77d3309df9dccf4d152e38b46d3e23883582ea Mon Sep 17 00:00:00 2001 From: Mattia Basaglia Date: Thu, 20 Jun 2024 10:02:49 +0200 Subject: [PATCH 1/3] Old bodymovin compat --- docs/compat.md | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 66 insertions(+) create mode 100644 docs/compat.md diff --git a/docs/compat.md b/docs/compat.md new file mode 100644 index 00000000..00cd6f70 --- /dev/null +++ b/docs/compat.md @@ -0,0 +1,65 @@ +# Compatibility with older versions + +This page describes breaking changes that have been introduced over time. + +You'd need to check `v` from {ref-link:animation/animation} to see the +the lottie is so old to need to worry about these. + +## [0,255] Colors + +Until `v` 4.1.9. + +Modern Lotties have [color](concepts.md#colors) components in the [0, 1] range. +Older ones have components in the [0, 255] range. + +Fix: Divide all color components by 255. + +## Static text document + +Until `v` 4.4.14. + +In {ref-link:text/text-data}, `d` was not animated. + +Fix: Wrap into an animated property + +`text_layer.t.d = {"a": 0, "k": text_layer.t.d}` + +## Shape closing + +Until `v` 4.4.18. + +{ref-link:shapes/path} objects had a `closed` property and `c` was not +present in the bezier data. + +Similarly, {ref-link:helpers/mask} had `cl` that worked the same way. + +Fix: For each {ref-link:shapes/path}, update all the keyframes +(or the non-animated value) of `ks`. +Do the same to fix `pt` in each {ref-link:helpers/mask}. + +## Old keyframe style + +Until `v` 5.0.0 (?). + +[Keyframes](concepts.md#keyframe) had an `e` property that specified +the end value for that keyframe (`s` marking the start value), +and the last keyframe would not have `s`. + +Fix: Ignore all the `e` in keyframes, but copy the `e` from the keyframe +before last into the last keyframe. + +`keyframes[keyframes.length - 1].s = keyframes[keyframes.length - 2].e` + + + +## Static text layer properties + +Until `v` 5.7.15. + +In {ref-link:text/text-follow-path} properties `r`, `a`, and `p` were +plain numbers instead of animated properties. + +Fix: Wrap all of those into animated properties + +`text_layer.t.p.a + {"a": 0, "k": text_layer.t.p.a}` + diff --git a/mkdocs.yml b/mkdocs.yml index 6a088466..8a4edf07 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -42,6 +42,7 @@ nav: - constants.md - text.md - expressions.md + - compat.md - "Playground": - "Builder": playground/builder.md - "JSON Editor": playground/json_editor.md From 5c8c74edcb071c286cf91077704ad3c55ff0fb46 Mon Sep 17 00:00:00 2001 From: Mattia Basaglia Date: Thu, 20 Jun 2024 12:12:52 +0200 Subject: [PATCH 2/3] Specify closed was a bool --- docs/compat.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/compat.md b/docs/compat.md index 00cd6f70..d75e3288 100644 --- a/docs/compat.md +++ b/docs/compat.md @@ -28,7 +28,7 @@ Fix: Wrap into an animated property Until `v` 4.4.18. -{ref-link:shapes/path} objects had a `closed` property and `c` was not +{ref-link:shapes/path} objects had a boolean `closed` property and `c` was not present in the bezier data. Similarly, {ref-link:helpers/mask} had `cl` that worked the same way. From 5e5bfc3bd5cb24480f314f74c3994cbd2c7139c4 Mon Sep 17 00:00:00 2001 From: Mattia Basaglia Date: Thu, 20 Jun 2024 12:15:23 +0200 Subject: [PATCH 3/3] Clarify conversion code --- docs/compat.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/compat.md b/docs/compat.md index d75e3288..0f45e6d2 100644 --- a/docs/compat.md +++ b/docs/compat.md @@ -5,6 +5,9 @@ This page describes breaking changes that have been introduced over time. You'd need to check `v` from {ref-link:animation/animation} to see the the lottie is so old to need to worry about these. +The code examples are just for illustrative purposes and are not to be +taken as a complete conversion code. + ## [0,255] Colors Until `v` 4.1.9. @@ -37,6 +40,8 @@ Fix: For each {ref-link:shapes/path}, update all the keyframes (or the non-animated value) of `ks`. Do the same to fix `pt` in each {ref-link:helpers/mask}. +`shape.ks.k.c = shape.closed ? 1 : 0` + ## Old keyframe style Until `v` 5.0.0 (?).