feat: Useful Readonly Shapes

This commit is contained in:
Syntriax 2024-01-26 19:05:17 +03:00
parent ceb29cc42f
commit 6a84c3ec1a
1 changed files with 6 additions and 0 deletions

View File

@ -8,6 +8,12 @@ namespace Syntriax.Engine.Physics2D.Primitives;
public record Shape(IList<Vector2D> Vertices) : IEnumerable<Vector2D>
{
public static readonly Shape Triangle = CreateNgon(3, Vector2D.Up);
public static readonly Shape Box = CreateNgon(4, Vector2D.One);
public static readonly Shape Pentagon = CreateNgon(5, Vector2D.Up);
public static readonly Shape Hexagon = CreateNgon(6, Vector2D.Right);
public Vector2D this[System.Index index] => Vertices[index];
public static Shape CreateCopy(Shape shape) => new(new List<Vector2D>(shape.Vertices));