From 57d97ba2e9e76eb02921fd71c45b62d391e7d940 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 4 Feb 2017 22:09:44 +0900 Subject: [PATCH] Make triangles look better in many cases. --- osu-framework | 2 +- osu.Game/Beatmaps/Drawables/BeatmapPanel.cs | 1 + osu.Game/Graphics/Backgrounds/Triangles.cs | 30 +++++++++++++++------ osu.Game/Overlays/Toolbar/ToolbarButton.cs | 4 ++- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/osu-framework b/osu-framework index 3c795346a7..f9627494e4 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 3c795346a777a9446d849cfe55ffeea744defe0f +Subproject commit f9627494e444d8b35eb20d418539ada15f258c4d diff --git a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs index af1f458462..c21a90a294 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs @@ -69,6 +69,7 @@ namespace osu.Game.Beatmaps.Drawables }, triangles = new Triangles { + TriangleScale = 2, RelativeSizeAxes = Axes.Both, ColourLight = OsuColour.FromHex(@"3a7285"), ColourDark = OsuColour.FromHex(@"123744") diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index f9bcf56d12..80b5a7a16e 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Textures; using osu.Framework.MathUtils; using OpenTK; using OpenTK.Graphics; +using System; namespace osu.Game.Graphics.Backgrounds { @@ -34,7 +35,14 @@ namespace osu.Game.Graphics.Backgrounds } } - private int aimTriangleCount => (int)((DrawWidth * DrawHeight) / 800 / triangleScale); + protected override void LoadComplete() + { + base.LoadComplete(); + for (int i = 0; i < aimTriangleCount; i++) + addTriangle(true); + } + + private int aimTriangleCount => (int)(DrawWidth * DrawHeight * 0.002f / (triangleScale * triangleScale)); protected override void Update() { @@ -42,20 +50,25 @@ namespace osu.Game.Graphics.Backgrounds foreach (Drawable d in Children) { - d.Position -= new Vector2(0, (float)(d.Scale.X * (50 / DrawHeight) * (Time.Elapsed / 880)) / triangleScale); + d.Position -= new Vector2(0, (float)(d.Scale.X * (50 / DrawHeight) * (Time.Elapsed / 950)) / triangleScale); if (d.DrawPosition.Y + d.DrawSize.Y * d.Scale.Y < 0) d.Expire(); } - bool useRandomX = Children.Count() < aimTriangleCount / 2; while (Children.Count() < aimTriangleCount) - addTriangle(useRandomX); - + addTriangle(false); } protected virtual Triangle CreateTriangle() { - var scale = triangleScale * RNG.NextSingle() * 0.4f + 0.2f; + float stdDev = 0.16f; + float mean = 0.5f; + + float u1 = 1 - RNG.NextSingle(); //uniform(0,1] random floats + float u2 = 1 - RNG.NextSingle(); + float randStdNormal = (float)(Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2)); //random normal(0,1) + var scale = Math.Max(triangleScale * (mean + stdDev * randStdNormal), 0.1f); //random normal(mean,stdDev^2) + const float size = 100; return new Triangle @@ -72,10 +85,11 @@ namespace osu.Game.Graphics.Backgrounds protected virtual Color4 GetTriangleShade() => Interpolation.ValueAt(RNG.NextSingle(), ColourDark, ColourLight, 0, 1); - private void addTriangle(bool randomX) + private void addTriangle(bool randomY) { var sprite = CreateTriangle(); - sprite.Position = new Vector2(RNG.NextSingle(), randomX ? RNG.NextSingle() : 1); + var triangleHeight = sprite.DrawHeight / DrawHeight; + sprite.Position = new Vector2(RNG.NextSingle(), randomY ? (RNG.NextSingle() * (1 + triangleHeight) - triangleHeight) : 1); Add(sprite); } } diff --git a/osu.Game/Overlays/Toolbar/ToolbarButton.cs b/osu.Game/Overlays/Toolbar/ToolbarButton.cs index 78235bc99c..13b8ba0108 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarButton.cs @@ -169,6 +169,7 @@ namespace osu.Game.Overlays.Toolbar { RelativeSizeAxes = Axes.Both; Masking = true; + MaskingSmoothness = 0; EdgeEffect = new EdgeEffect { Type = EdgeEffectType.Shadow, @@ -186,7 +187,8 @@ namespace osu.Game.Overlays.Toolbar new Triangles { RelativeSizeAxes = Axes.Both, - Alpha = 0.05f, + ColourLight = OsuColour.Gray(40), + ColourDark = OsuColour.Gray(20), }, }; }