2018-11-15 07:22:19 +00:00
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
2018-11-21 00:56:41 +00:00
|
|
|
|
using RhythmBullet.UI.Modular;
|
2018-11-13 01:54:33 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2018-11-21 00:56:41 +00:00
|
|
|
|
namespace RhythmBullet.Utilities.UI.Modular.Modules
|
2018-11-13 01:54:33 +00:00
|
|
|
|
{
|
|
|
|
|
class Image : UIModule
|
|
|
|
|
{
|
2018-11-21 01:00:27 +00:00
|
|
|
|
public float rotation = 0f;
|
2018-11-15 07:22:19 +00:00
|
|
|
|
public Texture2D Texture { get; set; }
|
|
|
|
|
public float ScaleX
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2018-11-21 00:12:02 +00:00
|
|
|
|
return (float)bounds.Width / Texture.Width;
|
2018-11-15 07:22:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2018-11-21 00:12:02 +00:00
|
|
|
|
bounds.Width = (int)(Texture.Width * value);
|
2018-11-15 07:22:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float ScaleY
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2018-11-21 00:12:02 +00:00
|
|
|
|
return (float)bounds.Height / Texture.Height;
|
2018-11-15 07:22:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2018-11-21 00:12:02 +00:00
|
|
|
|
bounds.Height = (int)(Texture.Height * value);
|
2018-11-15 07:22:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float Scale
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
2018-11-21 00:12:02 +00:00
|
|
|
|
bounds.Height = (int)(Texture.Height * value);
|
|
|
|
|
bounds.Width = (int)(Texture.Width * value);
|
2018-11-15 07:22:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
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.");
|
2018-11-21 00:12:02 +00:00
|
|
|
|
bounds = texture.Bounds;
|
2018-11-13 01:54:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Draw(SpriteBatch batch)
|
|
|
|
|
{
|
2018-11-21 01:00:27 +00:00
|
|
|
|
batch.Draw(Texture, bounds, null, color, rotation, origin, SpriteEffects.None, 0f);
|
2018-11-13 01:54:33 +00:00
|
|
|
|
base.Draw(batch);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|