1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 06:03:08 +08:00

Improve triangles distribution

This commit is contained in:
Andrei Zavatski 2022-11-15 11:49:53 +03:00
parent c7dc6db124
commit f27a5f977d

View File

@ -187,13 +187,27 @@ namespace osu.Game.Graphics.Backgrounds
{
TriangleParticle particle = CreateTriangle();
particle.Position = new Vector2(nextRandom(), randomY ? nextRandom() : 1);
particle.Position = getRandomPosition(randomY, particle.Scale);
particle.ColourShade = nextRandom();
particle.Colour = CreateTriangleShade(particle.ColourShade);
return particle;
}
private Vector2 getRandomPosition(bool randomY, float scale)
{
float y = 1;
if (randomY)
{
// since triangles are drawn from the top - allow them to be positioned a bit above the screen
float maxOffset = triangle_size * scale * 0.866f / DrawHeight;
y = Interpolation.ValueAt(nextRandom(), -maxOffset, 1f, 0f, 1f);
}
return new Vector2(nextRandom(), y);
}
/// <summary>
/// Creates a triangle particle with a random scale.
/// </summary>