A game framework written with osu! in mind.

Add `ColourInfo.GradientHorizontal` case for visual cross-comparison

+52 -12
+52 -12
osu.Framework.Tests/Visual/Drawables/TestSceneColourInterpolation.cs
··· 4 4 using System.Linq; 5 5 using NUnit.Framework; 6 6 using osu.Framework.Graphics; 7 + using osu.Framework.Graphics.Colour; 7 8 using osu.Framework.Graphics.Containers; 8 9 using osu.Framework.Graphics.Shapes; 10 + using osu.Framework.Graphics.Sprites; 9 11 using osu.Framework.Utils; 12 + using osuTK; 10 13 using osuTK.Graphics; 11 14 12 15 namespace osu.Framework.Tests.Visual.Drawables ··· 16 19 [Test] 17 20 public void TestColourInterpolatesInLinearSpace() 18 21 { 19 - FillFlowContainer lines = null; 22 + FillFlowContainer interpolatingLines = null; 20 23 21 - AddStep("load interpolated colours", () => Child = lines = new FillFlowContainer 24 + AddStep("load interpolated colours", () => 22 25 { 23 - Anchor = Anchor.Centre, 24 - Origin = Anchor.Centre, 25 - AutoSizeAxes = Axes.X, 26 - Height = 50f, 27 - ChildrenEnumerable = Enumerable.Range(0, 750).Select(i => new Box 26 + Child = new FillFlowContainer 28 27 { 29 - Width = 1f, 30 - RelativeSizeAxes = Axes.Y, 31 - Colour = Interpolation.ValueAt(i, Color4.Blue, Color4.Red, 0, 750), 32 - }), 28 + Anchor = Anchor.Centre, 29 + Origin = Anchor.Centre, 30 + AutoSizeAxes = Axes.Both, 31 + Direction = FillDirection.Vertical, 32 + Children = new Drawable[] 33 + { 34 + new SpriteText 35 + { 36 + Anchor = Anchor.CentreLeft, 37 + Origin = Anchor.CentreLeft, 38 + Text = $"{nameof(ColourInfo)}.{nameof(ColourInfo.GradientHorizontal)}(Blue, Red)" 39 + }, 40 + new Box 41 + { 42 + Anchor = Anchor.CentreLeft, 43 + Origin = Anchor.CentreLeft, 44 + Size = new Vector2(750f, 50f), 45 + Colour = ColourInfo.GradientHorizontal(Color4.Blue, Color4.Red), 46 + }, 47 + new SpriteText 48 + { 49 + Margin = new MarginPadding { Top = 20f }, 50 + Anchor = Anchor.CentreLeft, 51 + Origin = Anchor.CentreLeft, 52 + Text = $"{nameof(Interpolation)}.{nameof(Interpolation.ValueAt)}(Blue, Red) with 1px boxes", 53 + }, 54 + interpolatingLines = new FillFlowContainer 55 + { 56 + Anchor = Anchor.CentreLeft, 57 + Origin = Anchor.CentreLeft, 58 + AutoSizeAxes = Axes.X, 59 + Height = 50f, 60 + ChildrenEnumerable = Enumerable.Range(0, 750).Select(i => new Box 61 + { 62 + Width = 1f, 63 + RelativeSizeAxes = Axes.Y, 64 + Colour = Interpolation.ValueAt(i, Color4.Blue, Color4.Red, 0, 750), 65 + }), 66 + }, 67 + } 68 + }; 33 69 }); 34 70 35 - AddAssert("interpolation in linear space", () => lines.Children[lines.Children.Count / 2].Colour.AverageColour.Linear == new Color4(0.5f, 0f, 0.5f, 1f)); 71 + AddAssert("interpolation in linear space", () => 72 + { 73 + var middle = interpolatingLines.Children[interpolatingLines.Children.Count / 2]; 74 + return middle.Colour.AverageColour.Linear == new Color4(0.5f, 0f, 0.5f, 1f); 75 + }); 36 76 } 37 77 } 38 78 }