public static double lerp(double a, double b, @FloatRange(from = 0f, to = 1f) double percentage) { return a + percentage * (b - a); }
public static int lerp(int a, int b, @FloatRange(from = 0f, to = 1f) float percentage) { return (int) (a + percentage * (b - a)); }
public static float lerp(float a, float b, @FloatRange(from = 0f, to = 1f) float percentage) { return a + percentage * (b - a); }
/** * @see #setMinProgress(float) * @see #setMaxProgress(float) */ public void setMinAndMaxProgress( @FloatRange(from = 0f, to = 1f) float minProgress, @FloatRange(from = 0f, to = 1f) float maxProgress) { lottieDrawable.setMinAndMaxProgress(minProgress, maxProgress); }
/** * Sets the maximum progress that the animation will end at when playing or looping. */ public void setMaxProgress(@FloatRange(from = 0f, to = 1f) float endProgress) { lottieDrawable.setMaxProgress(endProgress); }
@FloatRange(from = 0f, to = 1f) private float getStartDelayProgress() { if (cachedStartDelayProgress == -1f) { cachedStartDelayProgress = keyframes.isEmpty() ? 0f : keyframes.get(0).getStartProgress(); } return cachedStartDelayProgress; }
@FloatRange(from = 0f, to = 1f) float getEndProgress() { if (cachedEndProgress == -1f) { cachedEndProgress = keyframes.isEmpty() ? 1f : keyframes.get(keyframes.size() - 1).getEndProgress(); } return cachedEndProgress; }
@FloatRange(from = 0f, to = 1f) public float getProgress() { return animator.getAnimatedValueAbsolute(); }
public void setProgress(@FloatRange(from = 0f, to = 1f) float progress) { lottieDrawable.setProgress(progress); }
@FloatRange(from = 0.0f, to = 1.0f) public float getProgress() { return lottieDrawable.getProgress(); }
public void setScrimAlpha(@FloatRange(from = 0f, to = 1f) float alpha) { if (scrimAlpha != alpha) { scrimAlpha = alpha; scrimPaint.setColor(ColorUtils.modifyAlpha(scrimColor, scrimAlpha)); postInvalidateOnAnimation(); } }
public boolean containsProgress(@FloatRange(from = 0f, to = 1f) float progress) { return progress >= getStartProgress() && progress < getEndProgress(); }
public static RippleDrawable createRipple(@ColorInt int color, @FloatRange(from = 0f, to = 1f) float alpha, boolean bounded) { color = ColorUtils.modifyAlpha(color, alpha); return new RippleDrawable(ColorStateList.valueOf(color), null, bounded ? new ColorDrawable(Color.WHITE) : null); }
/** * Returns the current value of the animation from 0 to 1 regardless * of the animation speed, direction, or min and max frames. */ @FloatRange(from = 0f, to = 1f) public float getAnimatedValueAbsolute() { if (composition == null) { return 0; } return (frame - composition.getStartFrame()) / (composition.getEndFrame() - composition.getStartFrame()); }
public void setProgress(@FloatRange(from = 0f, to = 1f) final float progress) { if (composition == null) { lazyCompositionTasks.add(new LazyCompositionTask() { @Override public void run(LottieComposition composition) { setProgress(progress); } }); return; } setFrame((int) MiscUtils.lerp(composition.getStartFrame(), composition.getEndFrame(), progress)); }
/** * Sets the maximum progress that the animation will end at when playing or looping. */ public void setMaxProgress(@FloatRange(from = 0f, to = 1f) final float maxProgress) { if (composition == null) { lazyCompositionTasks.add(new LazyCompositionTask() { @Override public void run(LottieComposition composition) { setMaxProgress(maxProgress); } }); return; } setMaxFrame((int) MiscUtils.lerp(composition.getStartFrame(), composition.getEndFrame(), maxProgress)); }
/** * Set the alpha component of {@code color} to be {@code alpha}. */ public static @CheckResult @ColorInt int modifyAlpha(@ColorInt int color, @FloatRange(from = 0f, to = 1f) float alpha) { return modifyAlpha(color, (int) (255f * alpha)); }
public static @ColorInt int scrimify(@ColorInt int color, @FloatRange(from = 0f, to = 1f) float lightnessMultiplier) { return scrimify(color, isDark(color), lightnessMultiplier); }
@Override public void setProgress(@FloatRange(from = 0f, to = 1f) float progress) { super.setProgress(progress); if (timeRemapping != null) { float duration = lottieDrawable.getComposition().getDuration(); long remappedTime = (long) (timeRemapping.getValue() * 1000); progress = remappedTime / duration; } if (layerModel.getTimeStretch() != 0) { progress /= layerModel.getTimeStretch(); } progress -= layerModel.getStartProgress(); for (int i = layers.size() - 1; i >= 0; i--) { layers.get(i).setProgress(progress); } }
/** * Returns the current value of the currently playing animation taking into * account direction, min and max frames. */ @Override @FloatRange(from = 0f, to = 1f) public float getAnimatedFraction() { if (composition == null) { return 0; } if (isReversed()) { return (getMaxFrame() - frame) / (getMaxFrame() - getMinFrame()); } else { return (frame - getMinFrame()) / (getMaxFrame() - getMinFrame()); } }