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

63 lines
1.4 KiB
C#
Raw Normal View History

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
2018-11-13 01:54:33 +00:00
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);
}
}
2018-11-13 01:54:33 +00:00
public Image(Texture2D texture)
{
Texture = texture ?? throw new ArgumentException("Image requires a texture.");
Bounds = texture.Bounds;
2018-11-13 01:54:33 +00:00
}
public override void Draw(SpriteBatch batch)
{
batch.Draw(Texture, Bounds, Color);
2018-11-13 01:54:33 +00:00
base.Draw(batch);
}
}
}