﻿namespace CodeCafeEngine
{
    /// <summary>
    /// This class defines an arbitrary shape with a set of points.
    /// </summary>
    public class Shape
    {
        /// <summary>
        /// Gets or sets the set of points in this shape.
        /// </summary>
        public Vec2[] Points { get; set; }

        public Shape() { }
        public Shape(Vec2[] points)
        {
            Points = points;
        }

        /// <summary>
        /// Get the width of this shape.
        /// </summary>
        public float GetWidth()
        {
            float minx1, miny1, maxx1, maxy1, avgx, avgy;
            Points.GetRectangularBounds(out minx1, out maxx1, out miny1, out maxy1, out avgx, out avgy);
            return maxx1 - minx1;
        }

        /// <summary>
        /// Get the height of this shape.
        /// </summary>
        public float GetHeight()
        {
            float minx1, miny1, maxx1, maxy1, avgx, avgy;
            Points.GetRectangularBounds(out minx1, out maxx1, out miny1, out maxy1, out avgx, out avgy);
            return maxy1 - miny1;
        }

        public Vec2 this[int i] { get { return Points[i]; } set { Points[i] = value; } }
    }
}
