A game framework written with osu! in mind.
at master 55 lines 2.0 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 osuTK; 5using osuTK.Graphics; 6using osu.Framework.Graphics.Colour; 7using osu.Framework.Graphics.Containers; 8 9namespace osu.Framework.Graphics.Effects 10{ 11 /// <summary> 12 /// Creates an outline around the drawable this effect gets applied to. 13 /// </summary> 14 public class OutlineEffect : IEffect<BufferedContainer> 15 { 16 /// <summary> 17 /// The strength of the outline. A higher strength means that the blur effect used to draw the outline fades slower. 18 /// Default is 1. 19 /// </summary> 20 public float Strength = 1f; 21 22 /// <summary> 23 /// The sigma value for the blur effect used to draw the outline. This controls over how many pixels the outline gets spread. 24 /// Default is <see cref="Vector2.One"/>. 25 /// </summary> 26 public Vector2 BlurSigma = Vector2.One; 27 28 /// <summary> 29 /// The color of the outline. Default is <see cref="Color4.Black"/>. 30 /// </summary> 31 public ColourInfo Colour = Color4.Black; 32 33 /// <summary> 34 /// Whether to automatically pad by the blur extent such that no clipping occurs at the sides of the effect. Default is false. 35 /// </summary> 36 public bool PadExtent; 37 38 /// <summary> 39 /// True if the effect should be cached. This is an optimization, but can cause issues if the drawable changes the way it looks without changing its size. 40 /// Turned off by default. 41 /// </summary> 42 public bool CacheDrawnEffect; 43 44 public BufferedContainer ApplyTo(Drawable drawable) => drawable.WithEffect(new BlurEffect 45 { 46 Strength = Strength, 47 Sigma = BlurSigma, 48 Colour = Colour, 49 PadExtent = PadExtent, 50 CacheDrawnEffect = CacheDrawnEffect, 51 52 DrawOriginal = true, 53 }); 54 } 55}