Optimize animation calculation

This commit is contained in:
David Hewitt 2023-04-15 12:34:48 +01:00 committed by Corentin Noël
parent 07f7c21482
commit 097cda8b6b

View File

@ -192,7 +192,11 @@ public class Gala.GestureTracker : Object {
* @returns The linear animation value at the specified percentage. * @returns The linear animation value at the specified percentage.
*/ */
public static float animation_value (float initial_value, float target_value, double percentage, bool rounded = false) { public static float animation_value (float initial_value, float target_value, double percentage, bool rounded = false) {
float value = ((target_value - initial_value) * (float) percentage) + initial_value; float value = initial_value;
if (initial_value != target_value) {
value = ((target_value - initial_value) * (float) percentage) + initial_value;
}
if (rounded) { if (rounded) {
value = Math.roundf (value); value = Math.roundf (value);