Lottie4J 1.3.0

1.3.0 Reads the Files You Actually Find

Lottie4J 1.3.0 is a bigger release than the recent fixes. It came out of using Lottie4J with the AnimatorFX Lottie importer, first as a reference renderer in its tests and then as a candidate for its parsing layer. That second use needs a parser that accepts what real-world files contain. (PR #15)

Files that used to be rejected now load

InputBeforeNow
Property with an expression ("x": "var …")file rejectedloaded; the expression is kept and written back, never evaluated
Image asset with an external file ("u": "images/")file rejectedavailable as Asset.directory()
Unknown layer type, blend mode, matte mode, line cap, …file rejectedlogged and read as absent
Shape of an unknown typefile rejectedread as UnknownShape, draws nothing
Property written as a bare number ("o": 100)file rejectedfixed value

Values that were read wrong

  • Frame rate, in point and out point are now Double. A frame rate of 29.97 was read as 29. FrameTiming.getFrameRate gives the exact rate and the player uses it for playback.
  • Solid color layers now use their sw and sh size. A solid used to fill three times the composition, whatever its size.
  • Keyframes in the pre-5 format no longer drop to 0 at the last keyframe.
  • A precomposition that contains itself no longer causes a StackOverflowError, and parents that run in a circle are handled.
  • A track matte named with tp is now the matte, instead of the neighbouring layer.
  • Hidden layers and shapes ("hd": true) are no longer drawn. A hidden layer still works as parent and matte.

Know what is not drawn

UnsupportedFeatures.find(animation) lists what a file uses that the player does not draw, with counts and layer names: expressions, time remapping, layer styles, most effects, repeaters, unknown shapes, missing precompositions and more.

For tests and tooling

  • LottiePlayer.snapshotFrame(double frame) renders a single frame into an image.
  • ImageSimilarity, a windowed, color- and alpha-aware SSIM, moved from the file viewer tests to com.lottie4j.fxplayer.util and is now public.
  • LottieFileLoader.load(InputStream) and loadJson(String), Animation.fonts() and Layer.styles() were added.
  • The file viewer now requires com.google.common, because Selenium’s HTTP client needs Guava and the viewer failed to start Chrome on the module path without it.

Breaking changes

  • Asset.shapeType is renamed to Asset.directory and is a String.
  • Animation.framesPerSecond(), inPoint(), outPoint() and Asset.frameRate() return Double instead of Integer, and BezierKeyframe.time() returns Double.
  • The fromValue methods of the definitions return null for an unknown value instead of throwing LottieModelDefinitionException.
  • An unknown shape keeps its type and name, but not its other members, when an animation is written again.

See the full changelog for the details, or the GitHub diff between 1.2.8 and 1.3.0.