Add pivot offset for rotations.

This commit is contained in:
2023-09-25 18:44:35 +02:00
parent ea2733f594
commit 8aab1132b6
8 changed files with 27 additions and 17 deletions

View File

@@ -78,9 +78,10 @@ namespace DaggerFramework.Rendering
Raylib.DrawCircle((int)_position.X, (int)_position.Y, radius, DaggerColorToRaylibColor(color));
}
public override void SetTransform(Vector2 position, float rotation)
public override void SetTransform(Vector2 position, Vector2 offset, float rotation = 0)
{
_position = position;
_offset = offset;
_rotation = rotation;
}
@@ -153,7 +154,7 @@ namespace DaggerFramework.Rendering
y = _position.Y,
width = size.X,
height = size.Y
}, Vector2.Zero, _rotation, DaggerColorToRaylibColor(color));
}, _offset, _rotation, DaggerColorToRaylibColor(color));
}
public override void DrawDebugText(string text, int fontSize, Color color)
@@ -203,7 +204,7 @@ namespace DaggerFramework.Rendering
private List<Texture2D> _texturePool = new();
private List<Raylib_cs.Font> _fontPool = new();
private Vector2 _position;
private Vector2 _position, _offset;
private float _rotation;
private Vector2 _windowSize;
}

View File

@@ -82,8 +82,9 @@ namespace DaggerFramework.Rendering
/// Sets transforms for the next draw operation.
/// </summary>
/// <param name="position">Global transform position.</param>
/// <param name="offset">Local offset point around which shapes will rotate.</param>
/// <param name="rotation">Rotation.</param>
public abstract void SetTransform(Vector2 position, float rotation = 0.0f);
public abstract void SetTransform(Vector2 position, Vector2 offset, float rotation = 0.0f);
/// <summary>
/// Sets the transform for the next draw operation.
/// </summary>

View File

@@ -102,7 +102,7 @@ namespace DaggerFramework.Rendering
}
/// <inheritdoc />
public override void SetTransform(Vector2 position, float rotation = 0)
public override void SetTransform(Vector2 position, Vector2 offset, float rotation = 0)
{
throw new NotImplementedException();
}