using RGB.NET.Core; using SkiaSharp; namespace Artemis.Core { /// /// Represents an RGB LED contained in an /// public class ArtemisLed : CorePropertyChanged { private SKRect _absoluteRenderRectangle; private SKRect _renderRectangle; internal ArtemisLed(Led led, ArtemisDevice device) { RgbLed = led; Device = device; CalculateRenderRectangle(); } /// /// 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, sized to match the render scale and positioned relative to the /// /// public SKRect RenderRectangle { get => _renderRectangle; private set => SetAndNotify(ref _renderRectangle, value); } /// /// Gets the rectangle covering the LED, sized to match the render scale /// public SKRect AbsoluteRenderRectangle { get => _absoluteRenderRectangle; private set => SetAndNotify(ref _absoluteRenderRectangle, value); } internal void CalculateRenderRectangle() { RenderRectangle = SKRect.Create( (RgbLed.LedRectangle.Location.X * Device.Surface.Scale).RoundToInt(), (RgbLed.LedRectangle.Location.Y * Device.Surface.Scale).RoundToInt(), (RgbLed.LedRectangle.Size.Width * Device.Surface.Scale).RoundToInt(), (RgbLed.LedRectangle.Size.Height * Device.Surface.Scale).RoundToInt() ); AbsoluteRenderRectangle = SKRect.Create( (RgbLed.AbsoluteLedRectangle.Location.X * Device.Surface.Scale).RoundToInt(), (RgbLed.AbsoluteLedRectangle.Location.Y * Device.Surface.Scale).RoundToInt(), (RgbLed.AbsoluteLedRectangle.Size.Width * Device.Surface.Scale).RoundToInt(), (RgbLed.AbsoluteLedRectangle.Size.Height * Device.Surface.Scale).RoundToInt() ); } /// 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); } } }