2018-11-15 07:22:19 +00:00
|
|
|
|
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
|
|
|
|
|
{
|
2018-11-15 07:22:19 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
2018-11-15 07:22:19 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
2018-11-15 07:22:19 +00:00
|
|
|
|
batch.Draw(Texture, Bounds, Color);
|
2018-11-13 01:54:33 +00:00
|
|
|
|
base.Draw(batch);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|