A game framework written with osu! in mind.
at master 115 lines 4.2 kB view raw
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. 2// See the LICENCE file in the repository root for full licence text. 3 4using osu.Framework.Extensions.Color4Extensions; 5using osu.Framework.Graphics; 6using osu.Framework.Graphics.Colour; 7using osu.Framework.Graphics.Shapes; 8using osu.Framework.Graphics.Sprites; 9using osu.Framework.Testing; 10using osuTK; 11using osuTK.Graphics; 12 13namespace osu.Framework.Tests.Visual.Drawables 14{ 15 public class TestSceneColourGradient : GridTestScene 16 { 17 public TestSceneColourGradient() 18 : base(4, 2) 19 { 20 Color4 transparentBlack = new Color4(0, 0, 0, 0); 21 22 ColourInfo[] colours = 23 { 24 new ColourInfo 25 { 26 TopLeft = Color4.Pink.ToLinear(), 27 BottomLeft = Color4.Pink.ToLinear(), 28 TopRight = Color4.SkyBlue.ToLinear(), 29 BottomRight = Color4.SkyBlue.ToLinear(), 30 }, 31 new ColourInfo 32 { 33 TopLeft = Color4.Pink, 34 BottomLeft = Color4.Pink, 35 TopRight = Color4.SkyBlue, 36 BottomRight = Color4.SkyBlue, 37 }, 38 new ColourInfo 39 { 40 TopLeft = Color4.White.ToLinear(), 41 BottomLeft = Color4.White.ToLinear(), 42 TopRight = Color4.Black.ToLinear(), 43 BottomRight = Color4.Black.ToLinear(), 44 }, 45 new ColourInfo 46 { 47 TopLeft = Color4.White, 48 BottomLeft = Color4.White, 49 TopRight = Color4.Black, 50 BottomRight = Color4.Black, 51 }, 52 new ColourInfo 53 { 54 TopLeft = Color4.White.ToLinear(), 55 BottomLeft = Color4.White.ToLinear(), 56 TopRight = Color4.Transparent.ToLinear(), 57 BottomRight = Color4.Transparent.ToLinear(), 58 }, 59 new ColourInfo 60 { 61 TopLeft = Color4.White, 62 BottomLeft = Color4.White, 63 TopRight = Color4.Transparent, 64 BottomRight = Color4.Transparent, 65 }, 66 new ColourInfo 67 { 68 TopLeft = Color4.White.ToLinear(), 69 BottomLeft = Color4.White.ToLinear(), 70 TopRight = transparentBlack.ToLinear(), 71 BottomRight = transparentBlack.ToLinear(), 72 }, 73 new ColourInfo 74 { 75 TopLeft = Color4.White, 76 BottomLeft = Color4.White, 77 TopRight = transparentBlack, 78 BottomRight = transparentBlack, 79 }, 80 }; 81 82 string[] labels = 83 { 84 "Colours (Linear)", 85 "Colours (sRGB)", 86 "White to black (Linear brightness gradient)", 87 "White to black (sRGB brightness gradient)", 88 "White to transparent white (Linear brightness gradient)", 89 "White to transparent white (sRGB brightness gradient)", 90 "White to transparent black (Linear brightness gradient)", 91 "White to transparent black (sRGB brightness gradient)", 92 }; 93 94 for (int i = 0; i < Rows * Cols; ++i) 95 { 96 Cell(i).AddRange(new Drawable[] 97 { 98 new SpriteText 99 { 100 Text = labels[i], 101 Font = new FontUsage(size: 20), 102 }, 103 new Box 104 { 105 RelativeSizeAxes = Axes.Both, 106 Anchor = Anchor.Centre, 107 Origin = Anchor.Centre, 108 Size = new Vector2(0.5f), 109 Colour = colours[i], 110 }, 111 }); 112 } 113 } 114 } 115}