Add pivot offset for rotations.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user