Nodes - Added color gradient easing node

Color ramp node - Fixed 1 and multiples of 1 being treated as 0
This commit is contained in:
Robert committed 2022-10-30 18:13:47 +01:00
1 parent 147e050e69
commit cbf2cd1736
5 files changed
+119 -2

No files matched your search

@@ -468,6 +468,8 @@ public class ColorGradient : IList<ColorGradientStop>, IList, INotifyCollectionC
{
_stops.Add(item);
item.ColorGradient = this;
// Update the position, reapplying the overlap-check in Position's setter
item.Position = item.Position;
item.PropertyChanged += ItemOnPropertyChanged;
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, _stops.IndexOf(item)));
@@ -624,4 +626,36 @@ public class ColorGradient : IList<ColorGradientStop>, IList, INotifyCollectionC
}
#endregion
public ColorGradient Interpolate(ColorGradient targetValue, float progress)
{
ColorGradient interpolated = new(this);
// Add new stops
if (targetValue.Count > interpolated.Count)
{
// Prefer the stops on a vacant position
foreach (ColorGradientStop stop in targetValue.Take(targetValue.Count - interpolated.Count))
interpolated.Add(new ColorGradientStop(GetColor(stop.Position), stop.Position));
}
// Interpolate stops
int index = 0;
foreach (ColorGradientStop stop in interpolated.ToList())
{
if (index < targetValue.Count)
{
ColorGradientStop targetStop = targetValue[index];
stop.Interpolate(targetStop, progress);
}
// Interpolate stops not on the target gradient
else
{
stop.Color = stop.Color.Interpolate(targetValue.GetColor(stop.Position), progress);
}
index++;
}
return interpolated;
}
}
@@ -95,4 +95,10 @@ public class ColorGradientStop : CorePropertyChanged
}
#endregion
public void Interpolate(ColorGradientStop targetValue, float progress)
{
Color = Color.Interpolate(targetValue.Color, progress);
Position = Position + ((targetValue.Position - Position) * progress);
}
}
@@ -237,7 +237,7 @@ public class LayerProperty<T> : CorePropertyChanged, ILayerProperty
}
/// <summary>
/// Gets or sets the base value of this layer property without any keyframes applied
/// Gets or sets the base value of this layer property without any keyframes or data bindings applied
/// </summary>
public T BaseValue
{