mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Layer properties - Added implicit operator to built-in types
This commit is contained in:
parent
97c85e238c
commit
a1c2e4ad5a
@ -24,5 +24,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
|
||||
// Don't allow color gradients to be null
|
||||
BaseValue ??= DefaultValue ?? new ColorGradient();
|
||||
}
|
||||
|
||||
public static implicit operator ColorGradient(ColorGradientLayerProperty p) => p.CurrentValue;
|
||||
}
|
||||
}
|
||||
@ -15,5 +15,8 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
|
||||
{
|
||||
throw new ArtemisCoreException("Enum properties do not support keyframes.");
|
||||
}
|
||||
|
||||
public static implicit operator T(EnumLayerProperty<T> p) => p.CurrentValue;
|
||||
public static implicit operator int(EnumLayerProperty<T> p) => Convert.ToInt32(p.CurrentValue);
|
||||
}
|
||||
}
|
||||
@ -12,5 +12,8 @@
|
||||
var diff = NextKeyframe.Value - CurrentKeyframe.Value;
|
||||
CurrentValue = CurrentKeyframe.Value + diff * keyframeProgressEased;
|
||||
}
|
||||
|
||||
public static implicit operator float(FloatLayerProperty p) => p.CurrentValue;
|
||||
public static implicit operator double(FloatLayerProperty p) => p.CurrentValue;
|
||||
}
|
||||
}
|
||||
@ -14,5 +14,9 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
|
||||
var diff = NextKeyframe.Value - CurrentKeyframe.Value;
|
||||
CurrentValue = (int) Math.Round(CurrentKeyframe.Value + diff * keyframeProgressEased, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
|
||||
public static implicit operator int(IntLayerProperty p) => p.CurrentValue;
|
||||
public static implicit operator float(IntLayerProperty p) => p.CurrentValue;
|
||||
public static implicit operator double(IntLayerProperty p) => p.CurrentValue;
|
||||
}
|
||||
}
|
||||
@ -16,5 +16,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
|
||||
{
|
||||
throw new ArtemisCoreException("Layer brush references do not support keyframes.");
|
||||
}
|
||||
|
||||
public static implicit operator LayerBrushReference(LayerBrushReferenceLayerProperty p) => p.CurrentValue;
|
||||
}
|
||||
}
|
||||
@ -29,5 +29,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
|
||||
{
|
||||
return (byte) Math.Max(0, Math.Min(255, value));
|
||||
}
|
||||
|
||||
public static implicit operator SKColor(SKColorLayerProperty p) => p.CurrentValue;
|
||||
}
|
||||
}
|
||||
@ -15,5 +15,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
|
||||
var yDiff = NextKeyframe.Value.Y - CurrentKeyframe.Value.Y;
|
||||
CurrentValue = new SKPoint(CurrentKeyframe.Value.X + xDiff * keyframeProgressEased, CurrentKeyframe.Value.Y + yDiff * keyframeProgressEased);
|
||||
}
|
||||
|
||||
public static implicit operator SKPoint(SKPointLayerProperty p) => p.CurrentValue;
|
||||
}
|
||||
}
|
||||
@ -15,5 +15,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
|
||||
var heightDiff = NextKeyframe.Value.Height - CurrentKeyframe.Value.Height;
|
||||
CurrentValue = new SKSize(CurrentKeyframe.Value.Width + widthDiff * keyframeProgressEased, CurrentKeyframe.Value.Height + heightDiff * keyframeProgressEased);
|
||||
}
|
||||
|
||||
public static implicit operator SKSize(SKSizeLayerProperty p) => p.CurrentValue;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user