rhythmbullet/RhythmBullet/Zer01HD/Utilities/UI/Modular/Modules/Image.cs

63 lines
1.4 KiB
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using RhythmBullet.Zer01HD.UI.Modular;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RhythmBullet.Zer01HD.Utilities.UI.Modular.Modules
{
class Image : UIModule
{
public Texture2D Texture { get; set; }
public float ScaleX
{
get
{
return (float)Bounds.Width / Texture.Width;
}
set
{
Bounds.Width = (int)(Texture.Width * value);
}
}
public float ScaleY
{
get
{
return (float)Bounds.Height / Texture.Height;
}
set
{
Bounds.Height = (int)(Texture.Height * value);
}
}
public float Scale
{
set
{
Bounds.Height = (int)(Texture.Height * value);
Bounds.Width = (int)(Texture.Width * value);
}
}
public Image(Texture2D texture)
{
Texture = texture ?? throw new ArgumentException("Image requires a texture.");
Bounds = texture.Bounds;
}
public override void Draw(SpriteBatch batch)
{
batch.Draw(Texture, Bounds, Color);
base.Draw(batch);
}
}
}