1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 12:53:11 +08:00

Merge pull request #25386 from EVAST9919/bar-graph-smooth

Ensure `BarGraph`'s draw quad is thick enough
This commit is contained in:
Dean Herbert 2023-11-08 17:24:37 +09:00 committed by GitHub
commit 626cfae3fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 8 deletions

View File

@ -17,18 +17,16 @@ namespace osu.Game.Tests.Visual.Online
{
BarGraph graph;
Children = new[]
Child = graph = new BarGraph
{
graph = new BarGraph
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(0.5f),
},
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(0.5f),
};
AddStep("values from 1-10", () => graph.Values = Enumerable.Range(1, 10).Select(i => (float)i));
AddStep("small values", () => graph.Values = Enumerable.Range(1, 10).Select(i => i * 0.01f).Concat(new[] { 100f }));
AddStep("values from 1-100", () => graph.Values = Enumerable.Range(1, 100).Select(i => (float)i));
AddStep("reversed values from 1-10", () => graph.Values = Enumerable.Range(1, 10).Reverse().Select(i => (float)i));
AddStep("empty values", () => graph.Values = Array.Empty<float>());
@ -36,6 +34,14 @@ namespace osu.Game.Tests.Visual.Online
AddStep("Top to bottom", () => graph.Direction = BarDirection.TopToBottom);
AddStep("Left to right", () => graph.Direction = BarDirection.LeftToRight);
AddStep("Right to left", () => graph.Direction = BarDirection.RightToLeft);
AddToggleStep("Toggle movement", enabled =>
{
if (enabled)
graph.MoveToY(-10, 1000).Then().MoveToY(10, 1000).Loop();
else
graph.ClearTransforms();
});
}
}
}

View File

@ -145,6 +145,13 @@ namespace osu.Game.Graphics.UserInterface
float barHeight = drawSize.Y * ((direction == BarDirection.TopToBottom || direction == BarDirection.BottomToTop) ? lengths[i] : barBreadth);
float barWidth = drawSize.X * ((direction == BarDirection.LeftToRight || direction == BarDirection.RightToLeft) ? lengths[i] : barBreadth);
if (barHeight == 0 || barWidth == 0)
continue;
// Apply minimum sizing to hide the fact that we don't have fractional anti-aliasing.
barHeight = Math.Max(barHeight, 1.5f);
barWidth = Math.Max(barWidth, 1.5f);
Vector2 topLeft;
switch (direction)