diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index 0eb5e90d3e..af492bacc9 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -176,7 +176,8 @@ namespace osu.Game.Graphics.Backgrounds TriangleParticle particle = CreateTriangle(); particle.Position = new Vector2(RNG.NextSingle(), randomY ? RNG.NextSingle() : 1); - particle.UpdateColour(colourDark, colourLight); + particle.ColourShade = RNG.NextSingle(); + particle.Colour = CreateTriangleShade(particle.ColourShade); return particle; } @@ -198,12 +199,18 @@ namespace osu.Game.Graphics.Backgrounds return new TriangleParticle { Scale = scale }; } + /// + /// Creates a shade of colour for the triangles. + /// + /// The colour. + protected virtual Color4 CreateTriangleShade(float shade) => Interpolation.ValueAt(shade, colourDark, colourLight, 0, 1); + private void updateColours() { for (int i = 0; i < parts.Count; i++) { TriangleParticle newParticle = parts[i]; - newParticle.UpdateColour(colourDark, colourLight); + newParticle.Colour = CreateTriangleShade(newParticle.ColourShade); parts[i] = newParticle; } } @@ -286,7 +293,7 @@ namespace osu.Game.Graphics.Backgrounds } } - protected class TriangleParticle : IComparable + protected struct TriangleParticle : IComparable { /// /// The position of the top vertex of the triangle. @@ -297,7 +304,7 @@ namespace osu.Game.Graphics.Backgrounds /// The colour shade of the triangle. /// This is needed for colour recalculation of visible triangles when or is changed. /// - private readonly float colourShade = RNG.NextSingle(); + public float ColourShade; /// /// The colour of the triangle. @@ -309,11 +316,6 @@ namespace osu.Game.Graphics.Backgrounds /// public float Scale; - public void UpdateColour(Color4 colourDark, Color4 colourLight) - { - Colour = Interpolation.ValueAt(colourShade, colourDark, colourLight, 0, 1); - } - /// /// Compares two s. This is a reverse comparer because when the /// triangles are added to the particles list, they should be drawn from largest to smallest