1
0
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:
SpoinkyNL 2020-06-03 20:09:28 +02:00
parent 97c85e238c
commit a1c2e4ad5a
8 changed files with 20 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}