Added offset to be used instead of origin in spritebatch does things I don't want it to do. Also added a project to more easily test this library.

This commit is contained in:
2019-03-01 23:10:53 -06:00
parent 051f3b04b5
commit f311cc38f3
13 changed files with 352 additions and 12 deletions

View File

@@ -18,17 +18,17 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
/// <summary>
/// The texture to be rendered.
/// </summary>
public Texture2D Texture { get; set; }
public Texture2D texture;
/// <summary>
/// Scale of of the X axis.
/// </summary>
public float ScaleX { get { return (float)bounds.Width / Texture.Width; } set { bounds.Width = (int)(Texture.Width * value); } }
public float ScaleX { get { return (float)bounds.Width / texture.Width; } set { bounds.Width = (int)(texture.Width * value); } }
/// <summary>
/// Scale of the Y axis.
/// </summary>
public float ScaleY { get { return (float)bounds.Height / Texture.Height; } set { bounds.Height = (int)(Texture.Height * value); } }
public float ScaleY { get { return (float)bounds.Height / texture.Height; } set { bounds.Height = (int)(texture.Height * value); } }
/// <summary>
/// Sets scale of X and Y.
@@ -41,7 +41,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
/// <param name="texture">Texture to use.</param>
public Image(Texture2D texture)
{
Texture = texture ?? throw new ArgumentException("Image requires a texture.");
this.texture = texture ?? throw new ArgumentException("Image requires a texture.");
bounds = texture.Bounds;
}
@@ -51,7 +51,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
/// <param name="batch">The batch to use.</param>
public override void Draw(SpriteBatch batch)
{
batch.Draw(Texture, bounds, null, color, rotation, origin, SpriteEffects.None, 0f);
batch.Draw(texture, bounds, null, color, rotation, origin, SpriteEffects.None, 0f);
base.Draw(batch);
}
@@ -67,7 +67,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
{
this.color = color;
this.rotation = rotation;
this.origin = origin;
this.offset = origin;
bounds = destination;
Draw(spriteBatch);
}