public class

ImageAnimation

extends Image
java.lang.Object
   ↳ net.pierrox.lightning_launcher.script.api.Image
     ↳ net.pierrox.lightning_launcher.script.api.ImageAnimation

Class Overview

A kind of image which can play an animation (often loaded from GIF files). Note: as of today backgrounds and icon layers do not support animations, only the first frame will be displayed.

Summary

Public Methods
AnimationDecoder getDecoder()
int getFrameCount()
Return the number of frames in this animation.
int getFrameDuration(int index)
Return the delay for the frame at a given index
ImageBitmap getFrameImage(int index)
Return the image at a given index.
int getHeight()
Return the image height
int getLoopCount()
Return the maximal number of loop set (can be modified with #start).
int getTotalDuration()
Return the sum of all frames duration.
int getWidth()
Return the image width
boolean isPlaying()
Return true when the animation is playing.
boolean saveToFile(String path)
Save the animation to file using the GIF format.
void setFrameCount(int count)
Change the number of frames for this animation.
void setFrameDuration(int index, int delay)
Set the duration for a frame, in milliseconds.
void setLoopCount(int count)
Set the maximum number of times to play the animation.
void start()
Start (or restart) the animation.
void stop()
Stop the animation.
[Expand]
Inherited Methods
From class net.pierrox.lightning_launcher.script.api.Image
From class java.lang.Object

Public Methods

public AnimationDecoder getDecoder ()

public int getFrameCount ()

Return the number of frames in this animation.

public int getFrameDuration (int index)

Return the delay for the frame at a given index

Returns
  • the frame duration, or 0 if index is out of bounds

public ImageBitmap getFrameImage (int index)

Return the image at a given index. If this image is modified using draw(), call update() to validate changes.

Returns
  • an ImageBitmap, or null if index is out of bounds

public int getHeight ()

Return the image height

public int getLoopCount ()

Return the maximal number of loop set (can be modified with #start).

public int getTotalDuration ()

Return the sum of all frames duration.

public int getWidth ()

Return the image width

public boolean isPlaying ()

Return true when the animation is playing.

public boolean saveToFile (String path)

Save the animation to file using the GIF format. Animated GIFs support a maximum of 256 colors and no transluceny (only binary tranparency): saved animations may appear differently when reloaded. This is an experimental and sub-optimal feature.

Parameters
path where to store the file
Returns
  • true if the operation succeeded

public void setFrameCount (int count)

Change the number of frames for this animation. When increasing the number of frames, existing frames are kept while new one are created fully transparent, with a default delay of 100ms. Decreasing the number of frames will also keep frames whose index is below the count, other will be freed. Warning: this will ensure that count images are allocated, this is a costly operation.

Parameters
count number of frames

public void setFrameDuration (int index, int delay)

Set the duration for a frame, in milliseconds.

public void setLoopCount (int count)

Set the maximum number of times to play the animation.

Parameters
count number of loops to play, use 0 for infinite

public void start ()

Start (or restart) the animation.

public void stop ()

Stop the animation.