-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move
DefaultSliderBody
to own class and make SliderBody
more abst…
…ract
- Loading branch information
Showing
4 changed files
with
37 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
osu.Game.Rulesets.Osu/Skinning/Default/DefaultSliderBody.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using osu.Game.Rulesets.Osu.Objects; | ||
using osuTK.Graphics; | ||
|
||
namespace osu.Game.Rulesets.Osu.Skinning.Default | ||
{ | ||
public partial class DefaultSliderBody : SliderBody | ||
{ | ||
protected override DrawableSliderPath CreateSliderPath() => new DefaultDrawableSliderPath(); | ||
|
||
private partial class DefaultDrawableSliderPath : DrawableSliderPath | ||
{ | ||
private const float opacity_at_centre = 0.3f; | ||
private const float opacity_at_edge = 0.8f; | ||
|
||
protected override Color4 ColourAt(float position) | ||
{ | ||
const float actual_to_visual_radius = OsuHitObject.OBJECT_RADIUS / OsuHitObject.VISUAL_OBJECT_RADIUS; | ||
|
||
position = 1 - (1 - position) * actual_to_visual_radius; | ||
|
||
if (position < 0.0) | ||
return Color4.Transparent; | ||
|
||
if (CalculatedBorderPortion != 0f && position <= CalculatedBorderPortion) | ||
return BorderColour; | ||
|
||
position -= CalculatedBorderPortion; | ||
return new Color4(AccentColour.R, AccentColour.G, AccentColour.B, (opacity_at_edge - (opacity_at_edge - opacity_at_centre) * position / GRADIENT_PORTION) * AccentColour.A); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters