1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:37:28 +08:00

Apply draw colour to segmented graph segments

This commit is contained in:
Bartłomiej Dach 2023-01-18 22:51:05 +01:00
parent e09b768a99
commit 903c37bf32
No known key found for this signature in database

View File

@ -7,10 +7,12 @@ using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Rendering;
using osu.Framework.Graphics.Shaders;
using osu.Framework.Graphics.Textures;
using osu.Framework.Utils;
using osuTK;
namespace osu.Game.Graphics.UserInterface
@ -154,7 +156,19 @@ namespace osu.Game.Graphics.UserInterface
segments.Sort();
}
private Colour4 getTierColour(int tier) => tier >= 0 ? tierColours[tier] : new Colour4(0, 0, 0, 0);
private ColourInfo getSegmentColour(SegmentInfo segment)
{
var tierColour = segment.Tier >= 0 ? tierColours[segment.Tier] : new Colour4(0, 0, 0, 0);
var ourColour = DrawColourInfo.Colour;
return new ColourInfo
{
TopLeft = tierColour * Interpolation.ValueAt<Colour4>(segment.Start, ourColour.TopLeft, ourColour.TopRight, 0, 1),
TopRight = tierColour * Interpolation.ValueAt<Colour4>(segment.End, ourColour.TopLeft, ourColour.TopRight, 0, 1),
BottomLeft = tierColour * Interpolation.ValueAt<Colour4>(segment.Start, ourColour.BottomLeft, ourColour.BottomRight, 0, 1),
BottomRight = tierColour * Interpolation.ValueAt<Colour4>(segment.End, ourColour.BottomLeft, ourColour.BottomRight, 0, 1)
};
}
protected override DrawNode CreateDrawNode() => new SegmentedGraphDrawNode(this);
@ -240,7 +254,7 @@ namespace osu.Game.Graphics.UserInterface
Vector2Extensions.Transform(topRight, DrawInfo.Matrix),
Vector2Extensions.Transform(bottomLeft, DrawInfo.Matrix),
Vector2Extensions.Transform(bottomRight, DrawInfo.Matrix)),
Source.getTierColour(segment.Tier));
Source.getSegmentColour(segment));
}
shader.Unbind();