1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00
Robert Beekman 36058efc4d Merge pull request #517 from Artemis-RGB/feature/color-calibration
Added Per device color calibration
2020-12-12 21:11:41 +01:00

70 lines
1.9 KiB
C#

using RGB.NET.Core;
using SkiaSharp;
namespace Artemis.Core
{
/// <summary>
/// Represents an RGB LED contained in an <see cref="ArtemisDevice" />
/// </summary>
public class ArtemisLed : CorePropertyChanged
{
private SKRect _absoluteRectangle;
private SKRect _rectangle;
internal ArtemisLed(Led led, ArtemisDevice device)
{
RgbLed = led;
Device = device;
CalculateRectangles();
}
/// <summary>
/// Gets the RGB.NET LED backing this Artemis LED
/// </summary>
public Led RgbLed { get; }
/// <summary>
/// Gets the device that contains this LED
/// </summary>
public ArtemisDevice Device { get; }
/// <summary>
/// Gets the rectangle covering the LED positioned relative to the<see cref="Device" />
/// </summary>
public SKRect Rectangle
{
get => _rectangle;
private set => SetAndNotify(ref _rectangle, value);
}
/// <summary>
/// Gets the rectangle covering the LED
/// </summary>
public SKRect AbsoluteRectangle
{
get => _absoluteRectangle;
private set => SetAndNotify(ref _absoluteRectangle, value);
}
internal void CalculateRectangles()
{
Rectangle = RgbLed.LedRectangle.ToSKRect();
AbsoluteRectangle = RgbLed.AbsoluteLedRectangle.ToSKRect();
}
/// <inheritdoc />
public override string ToString()
{
return RgbLed.ToString();
}
/// <summary>
/// Gets the color of this led, reverting the correction done to the parent device
/// </summary>
/// <returns></returns>
public Color GetOriginalColor()
{
return RgbLed.Color.DivideRGB(Device.RedScale, Device.GreenScale, Device.BlueScale);
}
}
}