mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Merge branch 'master' into catch-catcher
This commit is contained in:
@ -20,14 +20,19 @@ namespace osu.Game.Graphics
|
|||||||
public static class AccentedColourExtensions
|
public static class AccentedColourExtensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tweens the accent colour of a drawable to another colour.
|
/// Smoothly adjusts <see cref="IHasAccentColour.AccentColour"/> over time.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="accentedDrawable">The drawable to apply the accent colour to.</param>
|
/// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns>
|
||||||
/// <param name="newColour">The new accent colour.</param>
|
|
||||||
/// <param name="duration">The tween duration.</param>
|
|
||||||
/// <param name="easing">The tween easing.</param>
|
|
||||||
public static TransformSequence<T> FadeAccent<T>(this T accentedDrawable, Color4 newColour, double duration = 0, Easing easing = Easing.None)
|
public static TransformSequence<T> FadeAccent<T>(this T accentedDrawable, Color4 newColour, double duration = 0, Easing easing = Easing.None)
|
||||||
where T : IHasAccentColour
|
where T : IHasAccentColour
|
||||||
=> accentedDrawable.TransformTo(nameof(accentedDrawable.AccentColour), newColour, duration, easing);
|
=> accentedDrawable.TransformTo(nameof(accentedDrawable.AccentColour), newColour, duration, easing);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Smoothly adjusts <see cref="IHasAccentColour.AccentColour"/> over time.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns>
|
||||||
|
public static TransformSequence<T> FadeAccent<T>(this TransformSequence<T> t, Color4 newColour, double duration = 0, Easing easing = Easing.None)
|
||||||
|
where T : Drawable, IHasAccentColour
|
||||||
|
=> t.Append(o => o.FadeAccent(newColour, duration, easing));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
using osu.Framework.Caching;
|
||||||
|
|
||||||
namespace osu.Game.Graphics
|
namespace osu.Game.Graphics
|
||||||
{
|
{
|
||||||
@ -17,6 +18,7 @@ namespace osu.Game.Graphics
|
|||||||
private readonly Sprite spriteShadow;
|
private readonly Sprite spriteShadow;
|
||||||
private readonly Sprite spriteMain;
|
private readonly Sprite spriteMain;
|
||||||
|
|
||||||
|
private Cached layout = new Cached();
|
||||||
private readonly Container shadowVisibility;
|
private readonly Container shadowVisibility;
|
||||||
|
|
||||||
public SpriteIcon()
|
public SpriteIcon()
|
||||||
@ -71,16 +73,23 @@ namespace osu.Game.Graphics
|
|||||||
|
|
||||||
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
|
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
|
||||||
{
|
{
|
||||||
if ((invalidation & Invalidation.Colour) > 0)
|
if ((invalidation & Invalidation.Colour) > 0 && Shadow)
|
||||||
|
layout.Invalidate();
|
||||||
|
return base.Invalidate(invalidation, source, shallPropagate);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
if (!layout.IsValid)
|
||||||
{
|
{
|
||||||
//adjust shadow alpha based on highest component intensity to avoid muddy display of darker text.
|
//adjust shadow alpha based on highest component intensity to avoid muddy display of darker text.
|
||||||
//squared result for quadratic fall-off seems to give the best result.
|
//squared result for quadratic fall-off seems to give the best result.
|
||||||
var avgColour = (Color4)DrawInfo.Colour.AverageColour;
|
var avgColour = (Color4)DrawInfo.Colour.AverageColour;
|
||||||
|
|
||||||
spriteShadow.Alpha = (float)Math.Pow(Math.Max(Math.Max(avgColour.R, avgColour.G), avgColour.B), 2);
|
spriteShadow.Alpha = (float)Math.Pow(Math.Max(Math.Max(avgColour.R, avgColour.G), avgColour.B), 2);
|
||||||
}
|
|
||||||
|
|
||||||
return base.Invalidate(invalidation, source, shallPropagate);
|
layout.Validate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Shadow
|
public bool Shadow
|
||||||
|
Reference in New Issue
Block a user