1.0.12 & 1.0.12.1

+ Utility Methods for texture transformations

~ Fixed an issue, where the horizontal & vertical flip was wrongly applied
~ Added missing summaries
This commit is contained in:
Michel Fedde 2021-05-05 17:36:12 +02:00
parent a29a2cab53
commit f11a954b5a
10 changed files with 116 additions and 21 deletions

View file

@ -1,6 +1,8 @@
#region usings
using OpenTK;
using OpenTK.Graphics.ES10;
using SM.Base.Textures;
using SM.Base.Types;
#endregion
@ -34,6 +36,41 @@ namespace SM.Base.Drawing
return CalculateMatrix(Offset, Scale, Rotation);
}
/// <summary>
/// Sets the offset relative to the pixels of the texture.
/// </summary>
/// <param name="texture">The texture it should use.</param>
/// <param name="pixelLocation">The offset in pixel.</param>
public void SetOffsetRelative(Texture texture, Vector2 pixelLocation)
{
Vector2 textureSize = new Vector2(texture.Width, texture.Height);
Offset.Set( Vector2.Divide(pixelLocation, textureSize) );
}
/// <summary>
/// Sets the scale relative to the pixels of the texture.
/// </summary>
/// <param name="texture">The texture.</param>
/// <param name="rectangleSize">The scale in pixel.</param>
public void SetScaleRelative(Texture texture, Vector2 rectangleSize)
{
Vector2 textureSize = new Vector2(texture.Width, texture.Height);
Scale.Set( Vector2.Divide(rectangleSize, textureSize) );
}
/// <summary>
/// Sets the offset and scale relative to the pixels of the texture.
/// </summary>
/// <param name="texture">The texture.</param>
/// <param name="location">Offset in pixel</param>
/// <param name="rectangleSize">Scale in pixel.</param>
public void SetRectangleRelative(Texture texture, Vector2 location, Vector2 rectangleSize)
{
Vector2 textureSize = new Vector2(texture.Width, texture.Height);
Offset.Set(Vector2.Divide(location, textureSize));
Scale.Set(Vector2.Divide(rectangleSize, textureSize));
}
/// <summary>
/// Calculates a texture matrix.
/// </summary>