Add exponential fall-off of triangles' alpha values.

This commit is contained in:
Dean Herbert 2017-02-28 11:28:12 +09:00
parent 2e84188be7
commit aa9582c0fa
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
1 changed files with 10 additions and 0 deletions

View File

@ -10,6 +10,7 @@
using OpenTK;
using OpenTK.Graphics;
using System;
using osu.Framework.Graphics.Colour;
namespace osu.Game.Graphics.Backgrounds
{
@ -37,6 +38,12 @@ public class Triangles : Container<Triangle>
private float triangleScale = 1;
/// <summary>
/// Whether we should exponentially drop-off alpha values to improve the visual appearance of unbuffered fades.
/// This defaults to on as it is generally more aesthetically pleasing, but should be turned off in buffered contexts.
/// </summary>
public bool ExponentialAlphaAdjust = true;
public float TriangleScale
{
get { return triangleScale; }
@ -63,8 +70,11 @@ protected override void Update()
{
base.Update();
float adjustedAlpha = ExponentialAlphaAdjust ? (float)Math.Pow(((Color4)DrawInfo.Colour.Colour).A, 3) : 1;
foreach (var t in Children)
{
t.Alpha = adjustedAlpha;
t.Position -= new Vector2(0, (float)(t.Scale.X * (50 / DrawHeight) * (Time.Elapsed / 950)) / triangleScale);
if (ExpireOffScreenTriangles && t.DrawPosition.Y + t.DrawSize.Y * t.Scale.Y < 0)
t.Expire();