From cd8d3f6765b00fc9eeab8a14c622757c735c81a0 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 12 Jun 2016 04:17:46 +0200 Subject: [PATCH] Fixed lack of randomness in rapid calls of GetRandomRainbowColor --- Artemis/Artemis/Utilities/ColorHelpers.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Artemis/Artemis/Utilities/ColorHelpers.cs b/Artemis/Artemis/Utilities/ColorHelpers.cs index bdefa0ec5..fb96440e3 100644 --- a/Artemis/Artemis/Utilities/ColorHelpers.cs +++ b/Artemis/Artemis/Utilities/ColorHelpers.cs @@ -7,6 +7,8 @@ namespace Artemis.Utilities { public static class ColorHelpers { + private static readonly Random _rand = new Random(); + /// /// Comes up with a 'pure' psuedo-random color /// @@ -14,9 +16,8 @@ namespace Artemis.Utilities public static Color GetRandomRainbowColor() { var colors = new List(); - var rand = new Random(); for (var i = 0; i < 3; i++) - colors.Add(rand.Next(0, 256)); + colors.Add(_rand.Next(0, 256)); var highest = colors.Max(); var lowest = colors.Min(); @@ -31,9 +32,8 @@ namespace Artemis.Utilities public static System.Windows.Media.Color GetRandomRainbowMediaColor() { var colors = new List(); - var rand = new Random(); for (var i = 0; i < 3; i++) - colors.Add((byte) rand.Next(0, 256)); + colors.Add((byte)_rand.Next(0, 256)); var highest = colors.Max(); var lowest = colors.Min();