1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-21 11:12:55 +08:00
osu-lazer/osu.Game/Overlays/OverlayColourProvider.cs

81 lines
2.8 KiB
C#
Raw Normal View History

2020-01-24 17:24:35 +08:00
// 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;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Overlays
{
public class OverlayColourProvider
{
private readonly OverlayColourScheme colourScheme;
public OverlayColourProvider(OverlayColourScheme colourScheme)
{
this.colourScheme = colourScheme;
}
2020-01-26 17:42:23 +08:00
public Color4 Highlight1 => getColour(1, 0.7f);
public Color4 Content1 => getColour(0.4f, 1);
public Color4 Content2 => getColour(0.4f, 0.9f);
public Color4 Light1 => getColour(0.4f, 0.8f);
public Color4 Light2 => getColour(0.4f, 0.75f);
public Color4 Light3 => getColour(0.4f, 0.7f);
public Color4 Light4 => getColour(0.4f, 0.5f);
public Color4 Dark1 => getColour(0.2f, 0.35f);
public Color4 Dark2 => getColour(0.2f, 0.3f);
public Color4 Dark3 => getColour(0.2f, 0.25f);
public Color4 Dark4 => getColour(0.2f, 0.2f);
public Color4 Dark5 => getColour(0.2f, 0.15f);
public Color4 Dark6 => getColour(0.2f, 0.1f);
public Color4 Foreground1 => getColour(0.1f, 0.6f);
public Color4 Background1 => getColour(0.1f, 0.4f);
public Color4 Background2 => getColour(0.1f, 0.3f);
public Color4 Background3 => getColour(0.1f, 0.25f);
public Color4 Background4 => getColour(0.1f, 0.2f);
public Color4 Background5 => getColour(0.1f, 0.15f);
public Color4 Background6 => getColour(0.1f, 0.1f);
2020-01-26 17:39:15 +08:00
2020-01-26 17:42:23 +08:00
private Color4 getColour(float saturation, float lightness) => Color4.FromHsl(new Vector4(getBaseHue(colourScheme), saturation, lightness, 1));
2020-01-24 17:24:35 +08:00
// See https://github.com/ppy/osu-web/blob/4218c288292d7c810b619075471eaea8bbb8f9d8/app/helpers.php#L1463
private static float getBaseHue(OverlayColourScheme colourScheme)
{
switch (colourScheme)
{
default:
throw new ArgumentException($@"{colourScheme} colour scheme does not provide a hue value in {nameof(getBaseHue)}.");
case OverlayColourScheme.Red:
2020-01-26 17:41:21 +08:00
return 0;
2020-01-24 17:24:35 +08:00
case OverlayColourScheme.Pink:
2020-01-26 17:41:21 +08:00
return 333 / 360f;
2020-01-24 17:24:35 +08:00
case OverlayColourScheme.Orange:
2020-01-26 17:41:21 +08:00
return 46 / 360f;
2020-01-24 17:24:35 +08:00
case OverlayColourScheme.Green:
2020-01-26 17:41:21 +08:00
return 115 / 360f;
2020-01-24 17:24:35 +08:00
case OverlayColourScheme.Purple:
2020-01-26 17:41:21 +08:00
return 255 / 360f;
2020-01-24 17:24:35 +08:00
case OverlayColourScheme.Blue:
2020-01-26 17:41:21 +08:00
return 200 / 360f;
2020-01-24 17:24:35 +08:00
}
}
}
public enum OverlayColourScheme
{
Red,
Pink,
Orange,
Green,
Purple,
Blue
}
}