moved utilities for rhythmbullet to separate project for a better custom content loaders for the monogame pipeline as well as for future projects and of course learning how things work.
This commit is contained in:
63
Recrowned-Athenaeum/UI/Modular/Modules/Image.cs
Normal file
63
Recrowned-Athenaeum/UI/Modular/Modules/Image.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using RhythmBullet.UI.Modular;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RhythmBullet.Utilities.UI.Modular.Modules
|
||||
{
|
||||
class Image : UIModule
|
||||
{
|
||||
public float rotation = 0f;
|
||||
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, null, color, rotation, origin, SpriteEffects.None, 0f);
|
||||
base.Draw(batch);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user