TilemapEllipseObject.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using Microsoft.Xna.Framework;
  2. namespace MonoGame.Extended.Tilemaps
  3. {
  4. /// <summary>
  5. /// Represents an elliptical object in a tilemap.
  6. /// </summary>
  7. public class TilemapEllipseObject : TilemapObject
  8. {
  9. /// <summary>
  10. /// Gets or sets the size of the ellipse's bounding rectangle.
  11. /// </summary>
  12. public Vector2 Size { get; set; }
  13. /// <summary>
  14. /// Gets the center point of the ellipse.
  15. /// </summary>
  16. public Vector2 Center
  17. {
  18. get
  19. {
  20. return Position + Size * 0.5f;
  21. }
  22. }
  23. /// <summary>
  24. /// Gets the horizontal radius of the ellipse.
  25. /// </summary>
  26. public float RadiusX
  27. {
  28. get
  29. {
  30. return Size.X * 0.5f;
  31. }
  32. }
  33. /// <summary>
  34. /// Gets the vertical radius of the ellipse.
  35. /// </summary>
  36. public float RadiusY
  37. {
  38. get
  39. {
  40. return Size.Y * 0.5f;
  41. }
  42. }
  43. /// <inheritdoc/>
  44. public override RectangleF Bounds
  45. {
  46. get
  47. {
  48. return new RectangleF(Position.X, Position.Y, Size.X, Size.Y);
  49. }
  50. }
  51. /// <summary>
  52. /// Initializes a new instance of the <see cref="TilemapEllipseObject"/> class.
  53. /// </summary>
  54. /// <param name="id">The unique identifier for the object.</param>
  55. /// <param name="position">The position fo the top-left corner of the bounding rectangle.</param>
  56. /// <param name="size">The size of the bounding rectangle.</param>
  57. public TilemapEllipseObject(int id, Vector2 position, Vector2 size) : base(id, position)
  58. {
  59. Size = size;
  60. }
  61. }
  62. }