A game framework written with osu! in mind.
at master 89 lines 2.9 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.Graphics; 5using osu.Framework.Graphics.Containers; 6using osu.Framework.Graphics.Effects; 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 TestSceneHollowEdgeEffect : GridTestScene 16 { 17 public TestSceneHollowEdgeEffect() 18 : base(2, 2) 19 { 20 const float size = 60; 21 22 float[] cornerRadii = { 0, 0.5f, 0, 0.5f }; 23 float[] alphas = { 0.5f, 0.5f, 0, 0 }; 24 EdgeEffectParameters[] edgeEffects = 25 { 26 new EdgeEffectParameters 27 { 28 Type = EdgeEffectType.Glow, 29 Colour = Color4.Khaki, 30 Radius = size, 31 Hollow = true, 32 }, 33 new EdgeEffectParameters 34 { 35 Type = EdgeEffectType.Glow, 36 Colour = Color4.Khaki, 37 Radius = size, 38 Hollow = true, 39 }, 40 new EdgeEffectParameters 41 { 42 Type = EdgeEffectType.Glow, 43 Colour = Color4.Khaki, 44 Radius = size, 45 Hollow = true, 46 }, 47 new EdgeEffectParameters 48 { 49 Type = EdgeEffectType.Glow, 50 Colour = Color4.Khaki, 51 Radius = size, 52 Hollow = true, 53 }, 54 }; 55 56 for (int i = 0; i < Rows * Cols; ++i) 57 { 58 Cell(i).AddRange(new Drawable[] 59 { 60 new SpriteText 61 { 62 Text = $"{nameof(CornerRadius)}={cornerRadii[i]} {nameof(Alpha)}={alphas[i]}", 63 Font = new FontUsage(size: 20), 64 }, 65 new Container 66 { 67 Size = new Vector2(size), 68 Anchor = Anchor.Centre, 69 Origin = Anchor.Centre, 70 71 Masking = true, 72 EdgeEffect = edgeEffects[i], 73 CornerRadius = cornerRadii[i] * size, 74 75 Children = new Drawable[] 76 { 77 new Box 78 { 79 RelativeSizeAxes = Axes.Both, 80 Colour = Color4.Aqua, 81 Alpha = alphas[i], 82 }, 83 }, 84 }, 85 }); 86 } 87 } 88 } 89}