Mono XAML/Utility/Utility.cs
/// <summary>
/// Returns a sliced texture given a brush
/// </summary>
/// <param name="brush">Brush class from XAML Designer</param>
/// <param name="source">Slice of <paramref name="destination"/> to return as Texture2D</param>
/// <param name="destination">Rectangle to display in screen space</param>
/// <returns></returns>
Returns a sliced texture given a brush
Returns a sliced texture given a brush
public static Texture2D BrushToTexture(Brush brush, Rectangle source, Rectangle destination)
        {
            if (brush is GradientBrush gradient)
            {
                return GradientToTexture(gradient, source, destination);
            }
            else if (brush is SolidColorBrush solidColor)
            {
                return DefaultTextures.White;
            }
            else
            {
                throw new NotImplementedException("Cannot render " + brush.GetType());
            }
        }
public static Texture2D BrushToTexture ( Brush brush , Rectangle source , Rectangle destination ) { if ( brush is GradientBrush gradient ) { return GradientToTexture ( gradient , source , destination ) ; } else if ( brush is SolidColorBrush solidColor ) { return DefaultTextures . White ; } else { throw new NotImplementedException ( " " + brush . GetType ( ) ) ; } }
Returns a sliced texture given a brush
Returns a sliced texture given a brush
None
brush
Brush
Brush class from XAML Designer
Brush class from XAML Designer
source
Rectangle
Slice of  to return as Texture2D
Slice of to return as Texture2D
destination
Rectangle
Rectangle to display in screen space
Rectangle to display in screen space