1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-18 05:39:53 +08:00
Files
osu-lazer/osu.Game.Tests/Visual/Colours/TestSceneStarDifficultyColours.cs
T
StanR 3e7f0f4c61 Add star rating text gradient (#36292)
Implements https://github.com/ppy/osu-web/pull/12363

There's one less colour in the spectrum than in the [web
code](https://github.com/ppy/osu-web/pull/12363/changes#diff-a9bdefd7233ca98f7f89cd76213aba5d869ae0424c8e79d1e322abd3e43462fbR31)
because the spectrum was actually defined incorrectly and has [one less
domain entry than it
should](https://github.com/ppy/osu-web/pull/12363/changes#diff-a9bdefd7233ca98f7f89cd76213aba5d869ae0424c8e79d1e322abd3e43462fbR29).
I've chose to not add it because of consistency with the web and because
it looked pretty ugly (it was pretty much unreadable)

<img width="1361" height="814" alt="image"
src="https://github.com/user-attachments/assets/5f9d7a93-3e28-4b8c-952c-0abd6f8c2cc3"
/>
<img width="805" height="647" alt="image"
src="https://github.com/user-attachments/assets/b060cba7-3beb-4bb5-8d50-6210e8417715"
/>
2026-01-11 00:30:48 +09:00

86 lines
3.6 KiB
C#

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osuTK;
namespace osu.Game.Tests.Visual.Colours
{
public partial class TestSceneStarDifficultyColours : OsuTestScene
{
[Resolved]
private OsuColour colours { get; set; } = null!;
[Test]
public void TestColours()
{
AddStep("load colour displays", () =>
{
Child = new FillFlowContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5f),
ChildrenEnumerable = Enumerable.Range(0, 15).Select(i => new FillFlowContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(10f),
ChildrenEnumerable = Enumerable.Range(0, 10).Select(j =>
{
float difficulty = 1f * i + 0.1f * j;
var colour = colours.ForStarDifficulty(difficulty);
var textColour = colours.ForStarDifficultyText(difficulty);
return new FillFlowContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0f, 5f),
Children = new Drawable[]
{
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Font = FontUsage.Default.With(size: 10),
Text = $"BG: {colour.ToHex()}",
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Font = FontUsage.Default.With(size: 10),
Text = $"Text: {textColour.ToHex()}",
},
new StarRatingDisplay(new StarDifficulty(difficulty, 0))
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
}
}
};
})
})
};
});
}
}
}