You're breathtaking!
This commit is contained in:
42
Source/Engine/UI/GUI/Brushes/GPUTextureBrush.cs
Normal file
42
Source/Engine/UI/GUI/Brushes/GPUTextureBrush.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
|
||||
|
||||
namespace FlaxEngine.GUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementation of <see cref="IBrush"/> for <see cref="FlaxEngine.GPUTexture"/>.
|
||||
/// </summary>
|
||||
/// <seealso cref="IBrush" />
|
||||
public sealed class GPUTextureBrush : IBrush
|
||||
{
|
||||
/// <summary>
|
||||
/// The GPU texture.
|
||||
/// </summary>
|
||||
[HideInEditor]
|
||||
public GPUTexture Texture;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GPUTextureBrush"/> class.
|
||||
/// </summary>
|
||||
public GPUTextureBrush()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GPUTextureBrush"/> struct.
|
||||
/// </summary>
|
||||
/// <param name="texture">The GPU texture.</param>
|
||||
public GPUTextureBrush(GPUTexture texture)
|
||||
{
|
||||
Texture = texture;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Vector2 Size => Texture?.Size ?? Vector2.Zero;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Draw(Rectangle rect, Color color)
|
||||
{
|
||||
Render2D.DrawTexture(Texture, rect, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Source/Engine/UI/GUI/Brushes/IBrush.cs
Normal file
22
Source/Engine/UI/GUI/Brushes/IBrush.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
|
||||
|
||||
namespace FlaxEngine.GUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface that unifies input source textures, sprites, render targets, and any other brushes to be used in a more generic way.
|
||||
/// </summary>
|
||||
public interface IBrush
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the size of the image brush in pixels (if relevant).
|
||||
/// </summary>
|
||||
Vector2 Size { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Draws the specified image using <see cref="Render2D"/> graphics backend.
|
||||
/// </summary>
|
||||
/// <param name="rect">The draw area rectangle.</param>
|
||||
/// <param name="color">The color.</param>
|
||||
void Draw(Rectangle rect, Color color);
|
||||
}
|
||||
}
|
||||
54
Source/Engine/UI/GUI/Brushes/LinearGradientBrush.cs
Normal file
54
Source/Engine/UI/GUI/Brushes/LinearGradientBrush.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
|
||||
|
||||
namespace FlaxEngine.GUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementation of <see cref="IBrush"/> for linear color gradient (made of 2 color).
|
||||
/// </summary>
|
||||
/// <seealso cref="IBrush" />
|
||||
public sealed class LinearGradientBrush : IBrush
|
||||
{
|
||||
/// <summary>
|
||||
/// The brush start color.
|
||||
/// </summary>
|
||||
[EditorOrder(0), ExpandGroups, Tooltip("The brush start color.")]
|
||||
public Color StartColor;
|
||||
|
||||
/// <summary>
|
||||
/// The brush end color.
|
||||
/// </summary>
|
||||
[EditorOrder(1), Tooltip("The brush end color.")]
|
||||
public Color EndColor;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LinearGradientBrush"/> class.
|
||||
/// </summary>
|
||||
public LinearGradientBrush()
|
||||
{
|
||||
StartColor = Color.White;
|
||||
EndColor = Color.Black;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LinearGradientBrush"/> struct.
|
||||
/// </summary>
|
||||
/// <param name="startColor">The start color.</param>
|
||||
/// <param name="endColor">The end color.</param>
|
||||
public LinearGradientBrush(Color startColor, Color endColor)
|
||||
{
|
||||
StartColor = startColor;
|
||||
EndColor = endColor;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Vector2 Size => Vector2.One;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Draw(Rectangle rect, Color color)
|
||||
{
|
||||
var startColor = StartColor * color;
|
||||
var endColor = EndColor * color;
|
||||
Render2D.FillRectangle(rect, startColor, startColor, endColor, endColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
42
Source/Engine/UI/GUI/Brushes/MaterialBrush.cs
Normal file
42
Source/Engine/UI/GUI/Brushes/MaterialBrush.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
|
||||
|
||||
namespace FlaxEngine.GUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementation of <see cref="IBrush"/> for <see cref="FlaxEngine.MaterialBase"/> rendering.
|
||||
/// </summary>
|
||||
/// <seealso cref="IBrush" />
|
||||
public sealed class MaterialBrush : IBrush
|
||||
{
|
||||
/// <summary>
|
||||
/// The material.
|
||||
/// </summary>
|
||||
[ExpandGroups, Tooltip("The material to use for GUI control area rendering. It must be GUI domain.")]
|
||||
public MaterialBase Material;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MaterialBrush"/> class.
|
||||
/// </summary>
|
||||
public MaterialBrush()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MaterialBrush"/> struct.
|
||||
/// </summary>
|
||||
/// <param name="material">The material.</param>
|
||||
public MaterialBrush(Material material)
|
||||
{
|
||||
Material = material;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Vector2 Size => Vector2.One;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Draw(Rectangle rect, Color color)
|
||||
{
|
||||
Render2D.DrawMaterial(Material, rect, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
43
Source/Engine/UI/GUI/Brushes/SolidColorBrush.cs
Normal file
43
Source/Engine/UI/GUI/Brushes/SolidColorBrush.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
|
||||
|
||||
namespace FlaxEngine.GUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementation of <see cref="IBrush"/> for single color fill.
|
||||
/// </summary>
|
||||
/// <seealso cref="IBrush" />
|
||||
public sealed class SolidColorBrush : IBrush
|
||||
{
|
||||
/// <summary>
|
||||
/// The brush color.
|
||||
/// </summary>
|
||||
[ExpandGroups, Tooltip("The brush color.")]
|
||||
public Color Color;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SolidColorBrush"/> class.
|
||||
/// </summary>
|
||||
public SolidColorBrush()
|
||||
{
|
||||
Color = Color.Black;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SolidColorBrush"/> struct.
|
||||
/// </summary>
|
||||
/// <param name="color">The color.</param>
|
||||
public SolidColorBrush(Color color)
|
||||
{
|
||||
Color = color;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Vector2 Size => Vector2.One;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Draw(Rectangle rect, Color color)
|
||||
{
|
||||
Render2D.FillRectangle(rect, Color * color);
|
||||
}
|
||||
}
|
||||
}
|
||||
42
Source/Engine/UI/GUI/Brushes/SpriteBrush.cs
Normal file
42
Source/Engine/UI/GUI/Brushes/SpriteBrush.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
|
||||
|
||||
namespace FlaxEngine.GUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementation of <see cref="IBrush"/> for <see cref="FlaxEngine.Sprite"/>.
|
||||
/// </summary>
|
||||
/// <seealso cref="IBrush" />
|
||||
public sealed class SpriteBrush : IBrush
|
||||
{
|
||||
/// <summary>
|
||||
/// The sprite.
|
||||
/// </summary>
|
||||
[ExpandGroups]
|
||||
public SpriteHandle Sprite;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SpriteBrush"/> class.
|
||||
/// </summary>
|
||||
public SpriteBrush()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SpriteBrush"/> struct.
|
||||
/// </summary>
|
||||
/// <param name="sprite">The sprite.</param>
|
||||
public SpriteBrush(SpriteHandle sprite)
|
||||
{
|
||||
Sprite = sprite;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Vector2 Size => Sprite.IsValid ? Sprite.Size : Vector2.Zero;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Draw(Rectangle rect, Color color)
|
||||
{
|
||||
Render2D.DrawSprite(Sprite, rect, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
42
Source/Engine/UI/GUI/Brushes/TextureBrush.cs
Normal file
42
Source/Engine/UI/GUI/Brushes/TextureBrush.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
|
||||
|
||||
namespace FlaxEngine.GUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementation of <see cref="IBrush"/> for <see cref="FlaxEngine.Texture"/>.
|
||||
/// </summary>
|
||||
/// <seealso cref="IBrush" />
|
||||
public sealed class TextureBrush : IBrush
|
||||
{
|
||||
/// <summary>
|
||||
/// The texture.
|
||||
/// </summary>
|
||||
[ExpandGroups, Tooltip("The texture asset.")]
|
||||
public Texture Texture;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TextureBrush"/> class.
|
||||
/// </summary>
|
||||
public TextureBrush()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TextureBrush"/> struct.
|
||||
/// </summary>
|
||||
/// <param name="texture">The texture.</param>
|
||||
public TextureBrush(Texture texture)
|
||||
{
|
||||
Texture = texture;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Vector2 Size => Texture?.Size ?? Vector2.Zero;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Draw(Rectangle rect, Color color)
|
||||
{
|
||||
Render2D.DrawTexture(Texture, rect, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user