mirror of
https://github.com/ppy/osu.git
synced 2024-11-18 06:52:55 +08:00
66 lines
1.7 KiB
C#
66 lines
1.7 KiB
C#
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
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
|
|
};
|
|
}
|
|
}
|
|
}
|