1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

SKColor keyframe engine - Avoid overflowing bytes with certain easings

This commit is contained in:
Robert 2020-02-11 19:49:09 +01:00
parent 9b1d28840c
commit c3b296726e

View File

@ -21,11 +21,16 @@ namespace Artemis.Core.Models.Profile.KeyframeEngines
var alphaDiff = nextKeyframe.Value.Alpha - currentKeyframe.Value.Alpha;
return new SKColor(
(byte) (currentKeyframe.Value.Red + redDiff * KeyframeProgressEased),
(byte) (currentKeyframe.Value.Green + greenDiff * KeyframeProgressEased),
(byte) (currentKeyframe.Value.Blue + blueDiff * KeyframeProgressEased),
(byte)(currentKeyframe.Value.Alpha + alphaDiff * KeyframeProgressEased)
ClampToByte(currentKeyframe.Value.Red + redDiff * KeyframeProgressEased),
ClampToByte(currentKeyframe.Value.Green + greenDiff * KeyframeProgressEased),
ClampToByte(currentKeyframe.Value.Blue + blueDiff * KeyframeProgressEased),
ClampToByte(currentKeyframe.Value.Alpha + alphaDiff * KeyframeProgressEased)
);
}
private byte ClampToByte(float value)
{
return (byte) Math.Max(0, Math.Min(255, value));
}
}
}