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