// Copyright (c) Wojciech Figat. All rights reserved. using System; namespace FlaxEngine.GUI { /// /// Implementation of for . /// /// public sealed class GPUTextureBrush : IBrush, IEquatable { /// /// The GPU texture. /// [HideInEditor] public GPUTexture Texture; /// /// The texture sampling filter mode. /// [ExpandGroups] public BrushFilter Filter = BrushFilter.Linear; /// /// Initializes a new instance of the class. /// public GPUTextureBrush() { } /// /// Initializes a new instance of the struct. /// /// The GPU texture. public GPUTextureBrush(GPUTexture texture) { Texture = texture; } /// public Float2 Size => Texture != null ? Texture.Size : Float2.One; /// public void Draw(Rectangle rect, Color color) { if (Filter == BrushFilter.Point) Render2D.DrawTexturePoint(Texture, rect, color); else Render2D.DrawTexture(Texture, rect, color); } /// public bool Equals(GPUTextureBrush other) { return other != null && Texture == other.Texture && Filter == other.Filter; } /// public override bool Equals(object obj) { return obj is GPUTextureBrush other && Equals(other); } /// public override int GetHashCode() { return HashCode.Combine(Texture, (int)Filter); } /// public int CompareTo(object obj) { return Equals(obj) ? 1 : 0; } } }