mirror of
https://github.com/ppy/osu
synced 2025-01-09 23:59:44 +00:00
Change visible triangles colour when dark or light colour is changed
This commit is contained in:
parent
c73512a51c
commit
f70f25098b
@ -29,8 +29,29 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private const float edge_smoothness = 1;
|
private const float edge_smoothness = 1;
|
||||||
|
|
||||||
public Color4 ColourLight = Color4.White;
|
private Color4 colourLight = Color4.White;
|
||||||
public Color4 ColourDark = Color4.Black;
|
|
||||||
|
public Color4 ColourLight
|
||||||
|
{
|
||||||
|
get => colourLight;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
colourLight = value;
|
||||||
|
updateColours();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Color4 colourDark = Color4.Black;
|
||||||
|
|
||||||
|
public Color4 ColourDark
|
||||||
|
{
|
||||||
|
get => colourDark;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
colourDark = value;
|
||||||
|
updateColours();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether we want to expire triangles as they exit our draw area completely.
|
/// Whether we want to expire triangles as they exit our draw area completely.
|
||||||
@ -151,7 +172,8 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
TriangleParticle particle = CreateTriangle();
|
TriangleParticle particle = CreateTriangle();
|
||||||
|
|
||||||
particle.Position = new Vector2(RNG.NextSingle(), randomY ? RNG.NextSingle() : 1);
|
particle.Position = new Vector2(RNG.NextSingle(), randomY ? RNG.NextSingle() : 1);
|
||||||
particle.Colour = CreateTriangleShade();
|
particle.ColourShade = RNG.NextSingle();
|
||||||
|
particle.Colour = CreateTriangleShade(particle.ColourShade);
|
||||||
|
|
||||||
return particle;
|
return particle;
|
||||||
}
|
}
|
||||||
@ -177,7 +199,17 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
/// Creates a shade of colour for the triangles.
|
/// Creates a shade of colour for the triangles.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The colour.</returns>
|
/// <returns>The colour.</returns>
|
||||||
protected virtual Color4 CreateTriangleShade() => Interpolation.ValueAt(RNG.NextSingle(), ColourDark, ColourLight, 0, 1);
|
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.Colour = CreateTriangleShade(newParticle.ColourShade);
|
||||||
|
parts[i] = newParticle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override DrawNode CreateDrawNode() => new TrianglesDrawNode(this);
|
protected override DrawNode CreateDrawNode() => new TrianglesDrawNode(this);
|
||||||
|
|
||||||
@ -264,6 +296,12 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Vector2 Position;
|
public Vector2 Position;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The colour shade of the triangle.
|
||||||
|
/// This is needed for colour recalculation of visible triangles when <see cref="ColourDark"/> or <see cref="ColourLight"/> is changed.
|
||||||
|
/// </summary>
|
||||||
|
public float ColourShade;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The colour of the triangle.
|
/// The colour of the triangle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user