diff --git a/RGB.NET.Core/Devices/AbstractRGBDevice.cs b/RGB.NET.Core/Devices/AbstractRGBDevice.cs
index e1f9e10..cd76493 100644
--- a/RGB.NET.Core/Devices/AbstractRGBDevice.cs
+++ b/RGB.NET.Core/Devices/AbstractRGBDevice.cs
@@ -56,6 +56,7 @@ namespace RGB.NET.Core
}
private Rectangle _deviceRectangle;
+ ///
public Rectangle DeviceRectangle
{
get => _deviceRectangle;
diff --git a/RGB.NET.Core/Devices/IRGBDevice.cs b/RGB.NET.Core/Devices/IRGBDevice.cs
index c64f2ef..23278ba 100644
--- a/RGB.NET.Core/Devices/IRGBDevice.cs
+++ b/RGB.NET.Core/Devices/IRGBDevice.cs
@@ -29,10 +29,14 @@ namespace RGB.NET.Core
Size Size { get; }
///
- /// Gets the actual (scaled and rotated) of the .
+ /// Gets the actual of the .
+ /// This includes the .
///
Size ActualSize { get; }
-
+
+ ///
+ /// Gets a representing the logical location of the relative to the .
+ ///
Rectangle DeviceRectangle { get; }
///
diff --git a/RGB.NET.Core/Extensions/PointExtensions.cs b/RGB.NET.Core/Extensions/PointExtensions.cs
new file mode 100644
index 0000000..7c413e9
--- /dev/null
+++ b/RGB.NET.Core/Extensions/PointExtensions.cs
@@ -0,0 +1,37 @@
+using System;
+
+namespace RGB.NET.Core
+{
+ public static class PointExtensions
+ {
+ #region Methods
+
+ ///
+ /// Moves the specified by the given amount.
+ ///
+ /// The to move.
+ /// The x-ammount to move.
+ /// The y-ammount to move.
+ /// The new location of the point.
+ public static Point Translate(this Point point, double x = 0, double y = 0) => new Point(point.X + x, point.Y + y);
+
+ ///
+ /// Rotates the specified by the given amuont around the given origin.
+ ///
+ /// The to rotate.
+ /// The rotation.
+ /// The origin to rotate around. [0,0] if not set.
+ /// The new location of the point.
+ public static Point Rotate(this Point point, Rotation rotation, Point origin = new Point())
+ {
+ double sin = Math.Sin(rotation.Radians);
+ double cos = Math.Cos(rotation.Radians);
+
+ point = new Point(point.X - origin.X, point.Y - origin.Y);
+ point = new Point((point.X * cos) - (point.Y * sin), (point.X * sin) + (point.Y * cos));
+ return new Point(point.X + origin.X, point.Y + origin.Y); ;
+ }
+
+ #endregion
+ }
+}
diff --git a/RGB.NET.Core/Extensions/RectangleExtensions.cs b/RGB.NET.Core/Extensions/RectangleExtensions.cs
index f16842e..aae9b04 100644
--- a/RGB.NET.Core/Extensions/RectangleExtensions.cs
+++ b/RGB.NET.Core/Extensions/RectangleExtensions.cs
@@ -90,7 +90,7 @@ namespace RGB.NET.Core
/// Determines if the specified is contained within this .
///
/// The to test.
- ///
+ /// true if the rectangle contains the given point; otherwise false.
public static bool Contains(this Rectangle rect, Point point) => rect.Contains(point.X, point.Y);
///
@@ -98,33 +98,49 @@ namespace RGB.NET.Core
///
/// The X-location to test.
/// The Y-location to test.
- ///
+ /// true if the rectangle contains the given coordinates; otherwise false.
public static bool Contains(this Rectangle rect, double x, double y) => (rect.Location.X <= x) && (x < (rect.Location.X + rect.Size.Width))
- && (rect.Location.Y <= y) && (y < (rect.Location.Y + rect.Size.Height));
+ && (rect.Location.Y <= y) && (y < (rect.Location.Y + rect.Size.Height));
///
/// Determines if the specified is contained within this .
///
/// The to test.
- ///
+ /// true if the rectangle contains the given rect; otherwise false.
public static bool Contains(this Rectangle rect, Rectangle rect2) => (rect.Location.X <= rect2.Location.X) && ((rect2.Location.X + rect2.Size.Width) <= (rect.Location.X + rect.Size.Width))
- && (rect.Location.Y <= rect2.Location.Y) && ((rect2.Location.Y + rect2.Size.Height) <= (rect.Location.Y + rect.Size.Height));
-
- public static Point Translate(this Point point, double x = 0, double y = 0) => new Point(point.X + x, point.Y + y);
-
- public static Point Rotate(this Point point, Rotation rotation, Point origin = new Point())
- {
- double sin = Math.Sin(rotation.Radians);
- double cos = Math.Cos(rotation.Radians);
-
- point = new Point(point.X - origin.X, point.Y - origin.Y);
- point = new Point((point.X * cos) - (point.Y * sin), (point.X * sin) + (point.Y * cos));
- return new Point(point.X + origin.X, point.Y + origin.Y); ;
- }
+ && (rect.Location.Y <= rect2.Location.Y) && ((rect2.Location.Y + rect2.Size.Height) <= (rect.Location.Y + rect.Size.Height));
+ ///
+ /// Moves the specified by the given amount.
+ ///
+ /// The to move.
+ /// The amount to move.
+ /// The moved rectangle.
public static Rectangle Translate(this Rectangle rect, Point point) => rect.Translate(point.X, point.Y);
+
+ ///
+ /// Moves the specified by the given amount.
+ ///
+ /// The to move.
+ /// The x-ammount to move.
+ /// The y-ammount to move.
+ /// The moved rectangle.
public static Rectangle Translate(this Rectangle rect, double x = 0, double y = 0) => new Rectangle(rect.Location.Translate(x, y), rect.Size);
+ ///
+ /// Rotates the specified by the given amuont around the given origin.
+ ///
+ ///
+ /// The returned array of is filled with the new locations of the rectangle clockwise starting from the top left:
+ /// [0] = top left
+ /// [1] = top right
+ /// [2] = bottom right
+ /// [3] = bottom left
+ ///
+ /// The to rotate.
+ /// The rotation.
+ /// The origin to rotate around. [0,0] if not set.
+ /// A array of containing the new locations of the corners of the original rectangle.
public static Point[] Rotate(this Rectangle rect, Rotation rotation, Point origin = new Point())
{
Point[] points = {
diff --git a/RGB.NET.Core/Leds/Led.cs b/RGB.NET.Core/Leds/Led.cs
index 07ed513..8b6b310 100644
--- a/RGB.NET.Core/Leds/Led.cs
+++ b/RGB.NET.Core/Leds/Led.cs
@@ -46,6 +46,9 @@ namespace RGB.NET.Core
}
private Point _location;
+ ///
+ /// Gets or sets the relative location of the .
+ ///
public Point Location
{
get => _location;
@@ -60,6 +63,9 @@ namespace RGB.NET.Core
}
private Size _size;
+ ///
+ /// Gets or sets the size of the .
+ ///
public Size Size
{
get => _size;
@@ -74,6 +80,10 @@ namespace RGB.NET.Core
}
private Point _actualLocation;
+ ///
+ /// Gets the actual location of the .
+ /// This includes device-scaling and rotation.
+ ///
public Point ActualLocation
{
get => _actualLocation;
@@ -81,6 +91,10 @@ namespace RGB.NET.Core
}
private Size _actualSize;
+ ///
+ /// Gets the actual location of the .
+ /// This includes device-scaling.
+ ///
public Size ActualSize
{
get => _actualSize;
diff --git a/RGB.NET.Core/Positioning/Point.cs b/RGB.NET.Core/Positioning/Point.cs
index 38be165..9583863 100644
--- a/RGB.NET.Core/Positioning/Point.cs
+++ b/RGB.NET.Core/Positioning/Point.cs
@@ -149,6 +149,12 @@ namespace RGB.NET.Core
return new Point(point1.X / point2.X, point1.Y / point2.Y);
}
+ ///
+ /// Returns a new representing the multiplication of the and the provided .
+ ///
+ /// The .
+ /// The .
+ /// A new representing the multiplication of the and the provided .
public static Point operator *(Point point, Scale scale) => new Point(point.X * scale.Horizontal, point.Y * scale.Vertical);
#endregion
diff --git a/RGB.NET.Core/Positioning/Rotation.cs b/RGB.NET.Core/Positioning/Rotation.cs
index aca7f87..0f638ec 100644
--- a/RGB.NET.Core/Positioning/Rotation.cs
+++ b/RGB.NET.Core/Positioning/Rotation.cs
@@ -1,7 +1,15 @@
-using System;
+// ReSharper disable MemberCanBePrivate.Global
+// ReSharper disable UnusedMember.Global
+
+using System;
+using System.Diagnostics;
namespace RGB.NET.Core
{
+ ///
+ /// Represents an angular rotation.
+ ///
+ [DebuggerDisplay("[{Degrees}°]")]
public struct Rotation
{
#region Constants
@@ -14,15 +22,29 @@ namespace RGB.NET.Core
#region Properties & Fields
+ ///
+ /// Gets the angle in degrees.
+ ///
public double Degrees { get; }
+
+ ///
+ /// Gets the angle in radians.
+ ///
public double Radians { get; }
+ ///
+ /// Gets a bool indicating if the rotation is > 0.
+ ///
public bool IsRotated => !Degrees.EqualsInTolerance(0);
#endregion
#region Constructors
+ ///
+ /// Initializes a new instance of the class using the provided values.
+ ///
+ /// The rotation in degrees.
public Rotation(double degrees)
: this(degrees, degrees * DEGREES_RADIANS_CONVERSION)
{ }
@@ -37,18 +59,102 @@ namespace RGB.NET.Core
#region Methods
+ ///
+ /// Creates a new Rotation out of the given degree-angle.
+ ///
+ /// The angle in degrees.
+ /// The new rotation.
public static Rotation FromDegrees(double degrees) => new Rotation(degrees);
+
+ ///
+ /// Creates a new Rotation out of the given radian-angle.
+ ///
+ /// The angle in radians.
+ /// The new rotation.
public static Rotation FromRadians(double radians) => new Rotation(radians * RADIANS_DEGREES_CONVERSION, radians);
+ ///
+ /// Tests whether the specified is equivalent to this .
+ ///
+ /// The rotation to test.
+ /// true if is equivalent to this ; otherwise, false.
public bool Equals(Rotation other) => Degrees.EqualsInTolerance(other.Degrees);
+
+ ///
+ /// Tests whether the specified object is a and is equivalent to this .
+ ///
+ /// The object to test.
+ /// true if is a equivalent to this ; otherwise, false.
public override bool Equals(object obj) => obj is Rotation other && Equals(other);
+
+ ///
+ /// Returns a hash code for this .
+ ///
+ /// An integer value that specifies the hash code for this .
public override int GetHashCode() => Degrees.GetHashCode();
#endregion
#region Operators
+ ///
+ /// Returns a value that indicates whether two specified are equal.
+ ///
+ /// The first to compare.
+ /// The second to compare.
+ /// true if and are equal; otherwise, false.
+ public static bool operator ==(Rotation rotation1, Rotation rotation2) => rotation1.Equals(rotation2);
+
+ ///
+ /// Returns a value that indicates whether two specified are equal.
+ ///
+ /// The first to compare.
+ /// The second to compare.
+ /// true if and are not equal; otherwise, false.
+ public static bool operator !=(Rotation rotation1, Rotation rotation2) => !(rotation1 == rotation2);
+
+ ///
+ /// Returns a new representing the addition of the and the provided value.
+ ///
+ /// The .
+ /// The value to add.
+ /// A new representing the addition of the and the provided value.
+ public static Rotation operator +(Rotation rotation, double value) => new Rotation(rotation.Degrees + value);
+
+ ///
+ /// Returns a new representing the subtraction of the and the provided value.
+ ///
+ /// The .
+ /// The value to substract.
+ /// A new representing the subtraction of the and the provided value.
+ public static Rotation operator -(Rotation rotation, double value) => new Rotation(rotation.Degrees - value);
+
+ ///
+ /// Returns a new representing the multiplication of the and the provided value.
+ ///
+ /// The .
+ /// The value to multiply with.
+ /// A new representing the multiplication of the and the provided value.
+ public static Rotation operator *(Rotation rotation, double value) => new Rotation(rotation.Degrees * value);
+
+ ///
+ /// Returns a new representing the division of the and the provided value.
+ ///
+ /// The .
+ /// The value to device with.
+ /// A new representing the division of the and the provided value.
+ public static Rotation operator /(Rotation rotation, double value) => value.EqualsInTolerance(0) ? new Rotation(0) : new Rotation(rotation.Degrees / value);
+
+ ///
+ /// Converts a double to a .
+ ///
+ /// The rotation in degrees to convert.
public static implicit operator Rotation(double rotation) => new Rotation(rotation);
+
+ ///
+ /// Converts to a double representing the rotation in degrees.
+ ///
+ /// The rotatio to convert.
public static implicit operator double(Rotation rotation) => rotation.Degrees;
#endregion
diff --git a/RGB.NET.Core/Positioning/Scale.cs b/RGB.NET.Core/Positioning/Scale.cs
index 42558e5..04b8f09 100644
--- a/RGB.NET.Core/Positioning/Scale.cs
+++ b/RGB.NET.Core/Positioning/Scale.cs
@@ -1,19 +1,44 @@
-namespace RGB.NET.Core
+// ReSharper disable MemberCanBePrivate.Global
+// ReSharper disable UnusedMember.Global
+
+using System.Diagnostics;
+
+namespace RGB.NET.Core
{
+ ///
+ /// Represents a scaling.
+ ///
+ [DebuggerDisplay("[Horizontal: {Horizontal}, Vertical: {Vertical}]")]
public struct Scale
{
#region Properties & Fields
+ ///
+ /// Gets the horizontal scaling value.
+ ///
public double Horizontal { get; }
+
+ ///
+ /// Gets the vertical scaling value.
+ ///
public double Vertical { get; }
#endregion
#region Constructors
+ ///
+ /// Initializes a new instance of the class using the provided values.
+ ///
+ /// The value used for horizontal and vertical scaling. 0 if not set.
public Scale(double scale = 1.0) : this(scale, scale)
{ }
+ ///
+ /// Initializes a new instance of the class using the provided values.
+ ///
+ /// The value used for horizontal scaling.
+ /// The value used for vertical scaling.
public Scale(double horizontal, double vertical)
{
this.Horizontal = horizontal;
@@ -24,10 +49,31 @@
#region Methods
+ ///
+ /// Tests whether the specified is equivalent to this .
+ ///
+ /// The scale to test.
+ /// true if is equivalent to this ; otherwise, false.
public bool Equals(Scale other) => Horizontal.EqualsInTolerance(other.Horizontal) && Vertical.EqualsInTolerance(other.Vertical);
+
+ ///
+ /// Tests whether the specified object is a and is equivalent to this .
+ ///
+ /// The object to test.
+ /// true if is a equivalent to this ; otherwise, false.
public override bool Equals(object obj) => obj is Scale other && Equals(other);
+
+ ///
+ /// Returns a hash code for this .
+ ///
+ /// An integer value that specifies the hash code for this .
public override int GetHashCode() { unchecked { return (Horizontal.GetHashCode() * 397) ^ Vertical.GetHashCode(); } }
+ ///
+ /// Deconstructs the scale into the horizontal and vertical value.
+ ///
+ /// The horizontal scaling value.
+ /// The vertical scaling value.
public void Deconstruct(out double horizontalScale, out double verticalScale)
{
horizontalScale = Horizontal;
@@ -38,8 +84,60 @@
#region Operators
+ ///
+ /// Returns a value that indicates whether two specified are equal.
+ ///
+ /// The first to compare.
+ /// The second to compare.
+ /// true if and are equal; otherwise, false.
+ public static bool operator ==(Scale scale1, Scale scale2) => scale1.Equals(scale2);
+
+ ///
+ /// Returns a value that indicates whether two specified are equal.
+ ///
+ /// The first to compare.
+ /// The second to compare.
+ /// true if and are not equal; otherwise, false.
+ public static bool operator !=(Scale scale1, Scale scale2) => !(scale1 == scale2);
+
+ ///
+ /// Returns a new representing the addition of the and the provided value.
+ ///
+ /// The .
+ /// The value to add.
+ /// A new representing the addition of the and the provided value.
+ public static Scale operator +(Scale scale, double value) => new Scale(scale.Horizontal + value, scale.Vertical + value);
+
+ ///
+ /// Returns a new representing the subtraction of the and the provided value.
+ ///
+ /// The .
+ /// The value to substract.
+ /// A new representing the subtraction of the and the provided value.
+ public static Scale operator -(Scale scale, double value) => new Scale(scale.Horizontal - value, scale.Vertical - value);
+
+ ///
+ /// Returns a new representing the multiplication of the and the provided value.
+ ///
+ /// The .
+ /// The value to multiply with.
+ /// A new representing the multiplication of the and the provided value.
+ public static Scale operator *(Scale scale, double value) => new Scale(scale.Horizontal * value, scale.Vertical * value);
+
+ ///
+ /// Returns a new representing the division of the and the provided value.
+ ///
+ /// The .
+ /// The value to device with.
+ /// A new representing the division of the and the provided value.
+ public static Scale operator /(Scale scale, double value) => value.EqualsInTolerance(0) ? new Scale(0) : new Scale(scale.Horizontal / value, scale.Vertical / value);
+
+
+ ///
+ /// Converts a double to a .
+ ///
+ /// The scale value to convert.
public static implicit operator Scale(double scale) => new Scale(scale);
- public static implicit operator Scale((double horizontal, double vertical) scale) => new Scale(scale.horizontal, scale.vertical);
#endregion
}
diff --git a/RGB.NET.Core/Positioning/Size.cs b/RGB.NET.Core/Positioning/Size.cs
index 8342c4f..74f9153 100644
--- a/RGB.NET.Core/Positioning/Size.cs
+++ b/RGB.NET.Core/Positioning/Size.cs
@@ -94,6 +94,11 @@ namespace RGB.NET.Core
}
}
+ ///
+ /// Deconstructs the size into the width and height value.
+ ///
+ /// The width.
+ /// The height.
public void Deconstruct(out double width, out double height)
{
width = Width;
@@ -178,6 +183,12 @@ namespace RGB.NET.Core
/// A new representing the division of the and the provided factor.
public static Size operator /(Size size, double factor) => factor.EqualsInTolerance(0) ? Invalid : new Size(size.Width / factor, size.Height / factor);
+ ///
+ /// Returns a new representing the multiplication of the and the given .
+ ///
+ /// The to scale.
+ /// The scaling factor.
+ /// A new representing the multiplication of the and the given .
public static Size operator *(Size size, Scale scale) => new Size(size.Width * scale.Horizontal, size.Height * scale.Vertical);
#endregion