diff --git a/X10D/src/Drawing/RandomExtensions.cs b/X10D/src/Drawing/RandomExtensions.cs new file mode 100644 index 0000000..8f07e41 --- /dev/null +++ b/X10D/src/Drawing/RandomExtensions.cs @@ -0,0 +1,32 @@ +using System.Drawing; + +namespace X10D.Drawing; + +/// +/// Extension methods for . +/// +public static class RandomExtensions +{ + /// + /// Returns a random color. + /// + /// The instance. + /// A whose red, green, and blue components are all random, and whose alpha is 255 + /// is . + public static Color NextColor(this Random random) + { + if (random is null) + { + throw new ArgumentNullException(nameof(random)); + } + + int seed = random.Next(); + var seededRandom = new Random(seed); + + var r = (byte)(seededRandom.Next() % (byte.MaxValue + 1)); + var g = (byte)(seededRandom.Next() % (byte.MaxValue + 1)); + var b = (byte)(seededRandom.Next() % (byte.MaxValue + 1)); + + return Color.FromArgb(r, g, b); + } +} diff --git a/X10D/src/RandomExtensions/SystemNumerics/RandomExtensions.Numerics.cs b/X10D/src/Numerics/RandomExtensions.cs similarity index 99% rename from X10D/src/RandomExtensions/SystemNumerics/RandomExtensions.Numerics.cs rename to X10D/src/Numerics/RandomExtensions.cs index 810523c..ddc46a2 100644 --- a/X10D/src/RandomExtensions/SystemNumerics/RandomExtensions.Numerics.cs +++ b/X10D/src/Numerics/RandomExtensions.cs @@ -1,6 +1,6 @@ using System.Numerics; -namespace X10D.SystemNumerics; +namespace X10D.Numerics; /// /// Extension methods for . diff --git a/X10D/src/RandomExtensions/RandomExtensions.cs b/X10D/src/RandomExtensions/RandomExtensions.cs index 1b7d357..447cf99 100644 --- a/X10D/src/RandomExtensions/RandomExtensions.cs +++ b/X10D/src/RandomExtensions/RandomExtensions.cs @@ -1,5 +1,4 @@ -using System.Drawing; -using System.Globalization; +using System.Globalization; using System.Text; namespace X10D; @@ -52,29 +51,6 @@ public static class RandomExtensions return random.NextDouble() >= 0.5; } - /// - /// Returns a random color. - /// - /// The instance. - /// A whose red, green, and blue components are all random, and whose alpha is 255 - /// is . - public static Color NextColor(this Random random) - { - if (random is null) - { - throw new ArgumentNullException(nameof(random)); - } - - int seed = random.Next(); - var seededRandom = new Random(seed); - - var r = (byte)(seededRandom.Next() % (byte.MaxValue + 1)); - var g = (byte)(seededRandom.Next() % (byte.MaxValue + 1)); - var b = (byte)(seededRandom.Next() % (byte.MaxValue + 1)); - - return Color.FromArgb(r, g, b); - } - /// /// Returns a non-negative random double-precision floating point number that is less than the specified maximum. ///