Skip to content

Commit

Permalink
A bit more code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
djsime1 committed Jul 12, 2024
1 parent 2fb287d commit 1281fe2
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions GradientDriverEasing/GradientDriverEasing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,7 @@ private static Button CreatePositionEasingButton<T>(ValueGradientDriver<T> insta
btn.LocalPressed += (_, _) =>
{
int pCount = instance.Points.Count;
for (int i = 0; i < pCount; i++)
{
instance.Points[i].Position.Value = fFunc(min.Value, max.Value, (float)i / (pCount - 1));
}
for (int i = 0; i < pCount; i++) instance.Points[i].Position.Value = fFunc(min.Value, max.Value, (float)i / (pCount - 1));
};
return btn;
}
Expand Down Expand Up @@ -262,14 +259,8 @@ private static T ConfiguredLerp<T>(T a, T b, float ratio)
{
if (Config_LerpColorByHSV && (typeof(T) == typeof(colorX) || typeof(T) == typeof(color)))
{
if (a is colorX colorXa && b is colorX colorXb)
{
return (T)(object)HSVLerp(colorXa, colorXb, ratio);
}
else if (a is color colora && b is color colorb)
{
return (T)(object)HSVLerp(colora, colorb, ratio);
}
if (a is colorX colorXa && b is colorX colorXb) return (T)(object)HSVLerp(colorXa, colorXb, ratio);
else if (a is color colora && b is color colorb) return (T)(object)HSVLerp(colora, colorb, ratio);
}

return Config_UseUnclampedLerp ? Coder<T>.LerpUnclamped(a, b, ratio) : Coder<T>.Lerp(a, b, ratio);
Expand All @@ -286,10 +277,7 @@ private static color HSVLerp(color a, color b, float ratio)
return hsvc.ToRGB();
}

private static colorX HSVLerp(colorX a, colorX b, float ratio)
{
return new colorX(HSVLerp((color)a, (color)b, ratio)).SetProfile(a.Profile);
}
private static colorX HSVLerp(colorX a, colorX b, float ratio) => new colorX(HSVLerp((color)a, (color)b, ratio)).SetProfile(a.Profile);

private static bool IsFakeLerpType<T>() => FakeLerpTypes.Contains(typeof(T));

Expand Down

0 comments on commit 1281fe2

Please sign in to comment.