diff --git a/RGB.NET.Core/Devices/AbstractRGBDevice.cs b/RGB.NET.Core/Devices/AbstractRGBDevice.cs index f4db90ef..07663f3f 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDevice.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDevice.cs @@ -119,7 +119,7 @@ public virtual void Update(bool flushLeds = false) /// Applies all . /// if no ist specified the is used. /// - /// The enumerable of leds to convert. + /// The of led to convert. /// The enumerable of custom data and color tuples for the specified leds. [MethodImpl(MethodImplOptions.AggressiveInlining)] protected (object key, Color color) GetUpdateData(Led led) diff --git a/RGB.NET.Core/RGB.NET.Core.csproj b/RGB.NET.Core/RGB.NET.Core.csproj index 1022bf04..415101b4 100644 --- a/RGB.NET.Core/RGB.NET.Core.csproj +++ b/RGB.NET.Core/RGB.NET.Core.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net8.0 latest enable diff --git a/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj b/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj index ecf4ea78..c108b7cd 100644 --- a/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj +++ b/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net8.0 latest enable diff --git a/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj b/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj index 73017c6b..2e0c5fff 100644 --- a/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj +++ b/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net8.0 latest enable diff --git a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj index ee6cfcaf..54263196 100644 --- a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj +++ b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net8.0 latest enable diff --git a/RGB.NET.Devices.Corsair_Legacy/RGB.NET.Devices.Corsair_Legacy.csproj b/RGB.NET.Devices.Corsair_Legacy/RGB.NET.Devices.Corsair_Legacy.csproj index c80995d1..148ac071 100644 --- a/RGB.NET.Devices.Corsair_Legacy/RGB.NET.Devices.Corsair_Legacy.csproj +++ b/RGB.NET.Devices.Corsair_Legacy/RGB.NET.Devices.Corsair_Legacy.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net8.0 latest enable diff --git a/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj b/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj index df8e5475..28b54c19 100644 --- a/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj +++ b/RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net8.0 latest enable diff --git a/RGB.NET.Devices.Debug/RGB.NET.Devices.Debug.csproj b/RGB.NET.Devices.Debug/RGB.NET.Devices.Debug.csproj index 1f177287..3bee8a9a 100644 --- a/RGB.NET.Devices.Debug/RGB.NET.Devices.Debug.csproj +++ b/RGB.NET.Devices.Debug/RGB.NET.Devices.Debug.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net8.0 latest enable diff --git a/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj b/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj index 6ae10dd6..2bd68a2d 100644 --- a/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj +++ b/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net8.0 latest enable diff --git a/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj b/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj index 12f416f4..6c3067d8 100644 --- a/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj +++ b/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net8.0 latest enable diff --git a/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj b/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj index c249fc27..85255e4d 100644 --- a/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj +++ b/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net8.0 latest enable diff --git a/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj b/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj index 6b325210..9662dead 100644 --- a/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj +++ b/RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj @@ -1,6 +1,6 @@ - net8.0;net7.0;net6.0 + net8.0 latest enable diff --git a/RGB.NET.Devices.PicoPi/RGB.NET.Devices.PicoPi.csproj b/RGB.NET.Devices.PicoPi/RGB.NET.Devices.PicoPi.csproj index a2b134f7..9f216139 100644 --- a/RGB.NET.Devices.PicoPi/RGB.NET.Devices.PicoPi.csproj +++ b/RGB.NET.Devices.PicoPi/RGB.NET.Devices.PicoPi.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net8.0 latest enable diff --git a/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj b/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj index 36323999..199f17eb 100644 --- a/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj +++ b/RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net8.0 latest enable diff --git a/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj b/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj index 76525ce4..6ee494ad 100644 --- a/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj +++ b/RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net8.0 latest enable diff --git a/RGB.NET.Devices.WLED/RGB.NET.Devices.WLED.csproj b/RGB.NET.Devices.WLED/RGB.NET.Devices.WLED.csproj index 84ceafa6..fc71677d 100644 --- a/RGB.NET.Devices.WLED/RGB.NET.Devices.WLED.csproj +++ b/RGB.NET.Devices.WLED/RGB.NET.Devices.WLED.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net8.0 latest enable diff --git a/RGB.NET.Devices.WS281X/RGB.NET.Devices.WS281X.csproj b/RGB.NET.Devices.WS281X/RGB.NET.Devices.WS281X.csproj index 39f4d520..17930a7e 100644 --- a/RGB.NET.Devices.WS281X/RGB.NET.Devices.WS281X.csproj +++ b/RGB.NET.Devices.WS281X/RGB.NET.Devices.WS281X.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net8.0 latest enable diff --git a/RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj b/RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj index 37d84ab0..47808ff5 100644 --- a/RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj +++ b/RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net8.0 latest enable diff --git a/RGB.NET.HID/RGB.NET.HID.csproj b/RGB.NET.HID/RGB.NET.HID.csproj index 58b5b0f4..5edef088 100644 --- a/RGB.NET.HID/RGB.NET.HID.csproj +++ b/RGB.NET.HID/RGB.NET.HID.csproj @@ -1,6 +1,6 @@ - net8.0;net7.0;net6.0 + net8.0 latest enable diff --git a/RGB.NET.Layout/RGB.NET.Layout.csproj b/RGB.NET.Layout/RGB.NET.Layout.csproj index 473f4214..4b76a646 100644 --- a/RGB.NET.Layout/RGB.NET.Layout.csproj +++ b/RGB.NET.Layout/RGB.NET.Layout.csproj @@ -1,6 +1,6 @@ - net8.0;net7.0;net6.0 + net8.0 latest enable diff --git a/RGB.NET.Presets/Extensions/HPPHExtensions.cs b/RGB.NET.Presets/Extensions/HPPHExtensions.cs new file mode 100644 index 00000000..363b9bc5 --- /dev/null +++ b/RGB.NET.Presets/Extensions/HPPHExtensions.cs @@ -0,0 +1,27 @@ +using HPPH; +using RGB.NET.Core; + +namespace RGB.NET.Presets.Extensions; + +/// +/// Offers some extensions related to HPPH. +/// +public static class HPPHExtensions +{ + /// + /// Converts the given HPPH to a RGB.NET . + /// + /// The color to convert. + /// The converted color. + public static Color ToColor(this IColor color) => new(color.A, color.R, color.G, color.B); + + /// + /// Converts the given HPPH to a RGB.NET . + /// + /// The color to convert. + /// The color-type of the HPPH color. + /// The converted color. + public static Color ToColor(this T color) + where T : struct, IColor + => new(color.A, color.R, color.G, color.B); +} \ No newline at end of file diff --git a/RGB.NET.Presets/RGB.NET.Presets.csproj b/RGB.NET.Presets/RGB.NET.Presets.csproj index c7b6129e..d4959567 100644 --- a/RGB.NET.Presets/RGB.NET.Presets.csproj +++ b/RGB.NET.Presets/RGB.NET.Presets.csproj @@ -1,6 +1,6 @@  - net8.0;net7.0;net6.0 + net8.0 latest enable @@ -57,6 +57,10 @@ + + + + diff --git a/RGB.NET.Presets/Textures/ImageTexture.cs b/RGB.NET.Presets/Textures/ImageTexture.cs new file mode 100644 index 00000000..e63793a9 --- /dev/null +++ b/RGB.NET.Presets/Textures/ImageTexture.cs @@ -0,0 +1,91 @@ +using System; +using HPPH; +using RGB.NET.Core; +using RGB.NET.Presets.Extensions; + +namespace RGB.NET.Presets.Textures; + +/// +/// +/// Represents a texture drawing an . +/// +public sealed class ImageTexture : ITexture +{ + #region Properties & Fields + + private IImage _image; + + /// + /// The image drawn by this texture. + /// + public IImage Image + { + get => _image; + set + { + ArgumentNullException.ThrowIfNull(value); + _image = value; + } + } + + /// + public Size Size { get; } + + /// + public Color this[Point point] + { + get + { + int x = (int)MathF.Round((Size.Width - 1) * point.X.Clamp(0, 1)); + int y = (int)MathF.Round((Size.Height - 1) * point.Y.Clamp(0, 1)); + + return Image[x, y].ToColor(); + } + } + + /// + public Color this[Rectangle rectangle] + { + get + { + int x = (int)MathF.Round((Size.Width - 1) * rectangle.Location.X.Clamp(0, 1)); + int y = (int)MathF.Round((Size.Height - 1) * rectangle.Location.Y.Clamp(0, 1)); + int width = (int)MathF.Round(Size.Width * rectangle.Size.Width.Clamp(0, 1)); + int height = (int)MathF.Round(Size.Height * rectangle.Size.Height.Clamp(0, 1)); + + if ((width == 0) && (rectangle.Size.Width > 0)) width = 1; + if ((height == 0) && (rectangle.Size.Height > 0)) height = 1; + + return this[x, y, width, height]; + } + } + + /// + /// Gets the sampled color inside the specified region. + /// + /// The x-location of the region. + /// The y-location of the region. + /// The with of the region. + /// The height of the region. + /// The sampled color. + public Color this[int x, int y, int width, int height] => Image[x, y, width, height].Average().ToColor(); + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The image represented by the texture. +#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + public ImageTexture(IImage image) +#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + { + this.Image = image; + + Size = new Size(image.Width, image.Height); + } + + #endregion +} \ No newline at end of file diff --git a/RGB.NET.sln.DotSettings b/RGB.NET.sln.DotSettings index f0e61dd4..a13f3315 100644 --- a/RGB.NET.sln.DotSettings +++ b/RGB.NET.sln.DotSettings @@ -278,6 +278,7 @@ GEZ GSDK HID + HPPH HS HSV IBAN