1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 10:57:26 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Skinning/Default/SpinnerTicks.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

75 lines
2.2 KiB
C#
Raw Normal View History

// 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.
2018-04-13 17:19:50 +08:00
2017-05-18 18:40:20 +08:00
using System;
2020-07-20 16:48:35 +08:00
using System.Linq;
2017-05-18 18:40:20 +08:00
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2019-04-02 13:51:28 +08:00
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
2020-07-20 16:48:35 +08:00
using osu.Game.Graphics;
2020-12-04 19:21:53 +08:00
using osuTK;
using osuTK.Graphics;
2018-04-13 17:19:50 +08:00
2020-12-04 19:21:53 +08:00
namespace osu.Game.Rulesets.Osu.Skinning.Default
2017-05-18 18:40:20 +08:00
{
2020-07-20 16:48:35 +08:00
public partial class SpinnerTicks : Container, IHasAccentColour
2017-05-18 18:40:20 +08:00
{
public SpinnerTicks()
{
Origin = Anchor.Centre;
Anchor = Anchor.Centre;
RelativeSizeAxes = Axes.Both;
2018-04-13 17:19:50 +08:00
2020-07-20 14:19:17 +08:00
const float count = 8;
2018-04-13 17:19:50 +08:00
for (float i = 0; i < count; i++)
2017-05-18 18:40:20 +08:00
{
Add(new Container
{
2020-07-20 16:48:35 +08:00
Alpha = 0.4f,
Blending = BlendingParameters.Additive,
2017-05-18 18:40:20 +08:00
RelativePositionAxes = Axes.Both,
Masking = true,
CornerRadius = 5,
2020-07-20 16:52:59 +08:00
Size = new Vector2(60, 10),
2017-05-18 18:40:20 +08:00
Origin = Anchor.Centre,
Position = new Vector2(
2020-07-20 16:52:59 +08:00
0.5f + MathF.Sin(i / count * 2 * MathF.PI) / 2 * 0.83f,
0.5f + MathF.Cos(i / count * 2 * MathF.PI) / 2 * 0.83f
2017-05-18 18:40:20 +08:00
),
Rotation = -i / count * 360 + 90,
2017-05-18 18:40:20 +08:00
Children = new[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
}
}
});
}
}
2020-07-20 16:48:35 +08:00
public Color4 AccentColour
{
get => Colour;
set
{
Colour = value;
foreach (var c in Children.OfType<Container>())
{
c.EdgeEffect =
new EdgeEffectParameters
{
Type = EdgeEffectType.Glow,
Radius = 20,
Colour = value.Opacity(0.8f),
};
}
}
}
2017-05-18 18:40:20 +08:00
}
2018-01-05 19:21:19 +08:00
}