Implement Interpolation encoding

This commit is contained in:
Yoshi Askharoun
2025-01-30 14:32:11 -06:00
parent 7ed765ee2e
commit 72f338a729
+17 -1
View File
@@ -4,9 +4,11 @@
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using System.Text;
namespace Microsoft.Iris.Animations
{
public class Interpolation
public class Interpolation : IStringEncodable
{
public static readonly Interpolation Default = new Interpolation(InterpolationType.Linear);
private InterpolationType _type;
@@ -102,5 +104,19 @@ namespace Microsoft.Iris.Animations
}
public override int GetHashCode() => _type.GetHashCode() ^ _weight.GetHashCode() ^ _bezierHandle1.GetHashCode() ^ _bezierHandle2.GetHashCode() ^ _easePercent.GetHashCode();
public string EncodeString()
{
StringBuilder sb = new(Type.ToString());
if (Type is InterpolationType.Bezier)
sb.Append($", {BezierHandle1}, {BezierHandle2}");
else if (Type is InterpolationType.EaseOut or InterpolationType.EaseIn)
sb.Append($", {Weight}, {EasePercent}");
else if (Weight != 1.0)
sb.Append($", {Weight}");
return sb.ToString();
}
}
}