mirror of
https://github.com/ppy/osu.git
synced 2024-11-12 13:17:26 +08:00
63 lines
1.6 KiB
C#
63 lines
1.6 KiB
C#
|
using osu.Framework.Extensions.Color4Extensions;
|
|||
|
using osu.Framework.Graphics;
|
|||
|
using osu.Framework.Graphics.Containers;
|
|||
|
using osu.Framework.Graphics.Shapes;
|
|||
|
using osu.Game.Graphics;
|
|||
|
using OpenTK.Graphics;
|
|||
|
|
|||
|
namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces
|
|||
|
{
|
|||
|
public class GlowPiece : CompositeDrawable, IHasAccentColour
|
|||
|
{
|
|||
|
private const float glow_alpha = 0.7f;
|
|||
|
private const float glow_radius = 5;
|
|||
|
|
|||
|
public GlowPiece()
|
|||
|
{
|
|||
|
RelativeSizeAxes = Axes.Both;
|
|||
|
Masking = true;
|
|||
|
|
|||
|
InternalChild = new Box
|
|||
|
{
|
|||
|
RelativeSizeAxes = Axes.Both,
|
|||
|
Alpha = 0,
|
|||
|
AlwaysPresent = true
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
protected override void LoadComplete()
|
|||
|
{
|
|||
|
base.LoadComplete();
|
|||
|
updateGlow();
|
|||
|
}
|
|||
|
|
|||
|
private Color4 accentColour;
|
|||
|
public Color4 AccentColour
|
|||
|
{
|
|||
|
get { return accentColour; }
|
|||
|
set
|
|||
|
{
|
|||
|
if (accentColour == value)
|
|||
|
return;
|
|||
|
accentColour = value;
|
|||
|
|
|||
|
updateGlow();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void updateGlow()
|
|||
|
{
|
|||
|
if (!IsLoaded)
|
|||
|
return;
|
|||
|
|
|||
|
EdgeEffect = new EdgeEffectParameters
|
|||
|
{
|
|||
|
Type = EdgeEffectType.Glow,
|
|||
|
Colour = AccentColour.Opacity(glow_alpha),
|
|||
|
Radius = glow_radius,
|
|||
|
Hollow = true
|
|||
|
};
|
|||
|
}
|
|||
|
}
|
|||
|
}
|