using LemonUI.Extensions;
using System.Drawing;
namespace LemonUI.Elements
{
///
/// Base class for all of the 2D elements.
///
public abstract class BaseElement : I2Dimensional
{
#region Private Fields
///
/// The 1080 scaled position.
///
protected internal PointF literalPosition = PointF.Empty;
///
/// The relative position between 0 and 1.
///
protected internal PointF relativePosition = PointF.Empty;
///
/// The 1080 scaled size.
///
protected internal SizeF literalSize = SizeF.Empty;
///
/// The relative size between 0 and 1.
///
protected internal SizeF relativeSize = SizeF.Empty;
#endregion
#region Public Properties
///
/// The Position of the drawable.
///
public PointF Position
{
get
{
return literalPosition;
}
set
{
literalPosition = value;
Recalculate();
}
}
///
/// The Size of the drawable.
///
public SizeF Size
{
get
{
return literalSize;
}
set
{
literalSize = value;
Recalculate();
}
}
///
/// The Color of the drawable.
///
public Color Color { get; set; } = Color.FromArgb(255, 255, 255, 255);
///
/// The rotation of the drawable.
///
public float Heading { get; set; } = 0;
#endregion
#region Constructors
///
/// Creates a new with the specified Position and Size.
///
/// The position of the Element.
/// The size of the Element.
public BaseElement(PointF pos, SizeF size)
{
literalPosition = pos;
literalSize = size;
Recalculate();
}
#endregion
#region Private Functions
///
/// Recalculates the size and position of this item.
///
public virtual void Recalculate()
{
relativePosition = literalPosition.ToRelative();
relativeSize = literalSize.ToRelative();
}
#endregion
#region Public Functions
///
/// Draws the item on the screen.
///
public abstract void Draw();
#endregion
}
}