From 3e53b51bac0000ddde24579863615fad6ec2ffa2 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 21 Jul 2024 23:44:59 +0200 Subject: [PATCH 1/4] Removed support for old .NETs --- RGB.NET.Core/RGB.NET.Core.csproj | 2 +- RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj | 2 +- .../RGB.NET.Devices.CoolerMaster.csproj | 2 +- RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj | 2 +- .../RGB.NET.Devices.Corsair_Legacy.csproj | 2 +- RGB.NET.Devices.DMX/RGB.NET.Devices.DMX.csproj | 2 +- RGB.NET.Devices.Debug/RGB.NET.Devices.Debug.csproj | 2 +- RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj | 2 +- RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj | 2 +- RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj | 2 +- RGB.NET.Devices.OpenRGB/RGB.NET.Devices.OpenRGB.csproj | 2 +- RGB.NET.Devices.PicoPi/RGB.NET.Devices.PicoPi.csproj | 2 +- RGB.NET.Devices.Razer/RGB.NET.Devices.Razer.csproj | 2 +- RGB.NET.Devices.SteelSeries/RGB.NET.Devices.SteelSeries.csproj | 2 +- RGB.NET.Devices.WLED/RGB.NET.Devices.WLED.csproj | 2 +- RGB.NET.Devices.WS281X/RGB.NET.Devices.WS281X.csproj | 2 +- RGB.NET.Devices.Wooting/RGB.NET.Devices.Wooting.csproj | 2 +- RGB.NET.HID/RGB.NET.HID.csproj | 2 +- RGB.NET.Layout/RGB.NET.Layout.csproj | 2 +- RGB.NET.Presets/RGB.NET.Presets.csproj | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) 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/RGB.NET.Presets.csproj b/RGB.NET.Presets/RGB.NET.Presets.csproj index c7b6129e..f598320b 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 From 4c3875e561348fede925818b79eac48a237dd84d Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 21 Jul 2024 23:45:23 +0200 Subject: [PATCH 2/4] Fixed a doc comment --- RGB.NET.Core/Devices/AbstractRGBDevice.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From b1cf26b1e6a327f0b4a276cd54008d49b14632fa Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 21 Jul 2024 23:46:13 +0200 Subject: [PATCH 3/4] Added support for HPPH-images in presets --- RGB.NET.Presets/Extensions/HPPHExtensions.cs | 27 +++++++ RGB.NET.Presets/RGB.NET.Presets.csproj | 4 ++ RGB.NET.Presets/Textures/ImageTexture.cs | 76 ++++++++++++++++++++ RGB.NET.sln.DotSettings | 1 + 4 files changed, 108 insertions(+) create mode 100644 RGB.NET.Presets/Extensions/HPPHExtensions.cs create mode 100644 RGB.NET.Presets/Textures/ImageTexture.cs 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 f598320b..d4959567 100644 --- a/RGB.NET.Presets/RGB.NET.Presets.csproj +++ b/RGB.NET.Presets/RGB.NET.Presets.csproj @@ -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..fc05b741 --- /dev/null +++ b/RGB.NET.Presets/Textures/ImageTexture.cs @@ -0,0 +1,76 @@ +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 readonly IImage _image; + + /// + 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. + public ImageTexture(IImage image) + { + 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 From cfbbdc60691b536523989877dedcf8b9e1054b67 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 21 Jul 2024 23:52:06 +0200 Subject: [PATCH 4/4] Changed ImageTexture Image to be public --- RGB.NET.Presets/Textures/ImageTexture.cs | 25 +++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/RGB.NET.Presets/Textures/ImageTexture.cs b/RGB.NET.Presets/Textures/ImageTexture.cs index fc05b741..e63793a9 100644 --- a/RGB.NET.Presets/Textures/ImageTexture.cs +++ b/RGB.NET.Presets/Textures/ImageTexture.cs @@ -7,13 +7,26 @@ namespace RGB.NET.Presets.Textures; /// /// -/// Represents a texture drawing an . +/// Represents a texture drawing an . /// public sealed class ImageTexture : ITexture { #region Properties & Fields - private readonly IImage _image; + private IImage _image; + + /// + /// The image drawn by this texture. + /// + public IImage Image + { + get => _image; + set + { + ArgumentNullException.ThrowIfNull(value); + _image = value; + } + } /// public Size Size { get; } @@ -26,7 +39,7 @@ public Color this[Point point] 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(); + return Image[x, y].ToColor(); } } @@ -55,7 +68,7 @@ public Color this[Rectangle rectangle] /// 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(); + public Color this[int x, int y, int width, int height] => Image[x, y, width, height].Average().ToColor(); #endregion @@ -65,9 +78,11 @@ public Color this[Rectangle rectangle] /// 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; + this.Image = image; Size = new Size(image.Width, image.Height); }