using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Scoring
{
    internal class Triangle
    {
        /******************************GLOBAL CONSTANTS************************************/
        //NAME: POINTS_SIZE
        //TYPE: Integer
        //PURPOSE: 'POINTS_SIZE' is the size of the 'points' array
        private const int POINTS_SIZE = 3;
        //NAME: MIN_ARGB
        //TYPE: Integer
        //PURPOSE: 'MIN_ARGB' is the minimum value possible for an ARGB value
        private const int MIN_ARGB = 0;
        //NAME: MAX_ARGB
        //TYPE: Integer
        //PURPOSE: 'MAX_ARGB' is the maximum value possible for an ARGB value
        private const int MAX_ARGB = 255;
        /********************************DATA MEMBERS**************************************/
        //NAME: points
        //TYPE: Point, array; LENGTH: 3
        //PURPOSE: 'point' stores three points to draw a triangle
        private Point[] points;
        //NAME: color
        //TYPE: Color
        //PURPOSE: 'color' stores an ARGB value for a triangle
        private Color color;
        /**********************************PROPERTIES**************************************/
        //PROPERTY: Points, get
        //PURPOSE: Accessor function, returns the array of points of a triangle
        public Point[] Points
        {
            get { return points; }
        }
        //PROPERTY: Color, set; Color, get
        //PURPOSE: Mutator function, sets the color object of a triangle
        //         Accessor function, returns the color object of a triangle
        public Color Color
        {
            set { color = value; }
            get { return color; }
        }
        /**********************************FUNCTIONS***************************************/
        //FUNCTION: Triangle, constructor
        //PARAMETERS: Width and Height of the Bitmap image
        //PURPOSE: The following function is the Triangle constructor. It allocates memory for its data members and calls functions to
        //         generate points and generate the color for an individual triangle
        public Triangle(int width, int height)
        {
            //Console.WriteLine("in Triangle Constructor");
            points = new Point[POINTS_SIZE];
            color = new Color();

            //Console.WriteLine("before GeneratePoints");
            this.GeneratePoints(width, height);
            //Console.WriteLine(points);
            //Console.WriteLine("after GeneratePoints");
            //Console.WriteLine("before GenerateColor");
            this.GenerateColor();
            //Console.WriteLine("after GenerateColor");
        }
        //FUNCTION: GeneratePoints 
        //PARAMETERS: Width and Height of the Bitmap Image
        //PURPOSE: The function 'GeneratePoints' will fill the contents of a triangle's Point array with randomly generated value within a specified range
        public void GeneratePoints(int width, int height)
        {
            //Console.WriteLine("in GeneratePoints");
            int point_X, point_Y;
            Point temp_point;

            //Console.WriteLine("before loop");
            for (int i = 0; i < POINTS_SIZE; i++)
            {
                point_X = RndNumGen.Next(0, width);
                //Console.WriteLine("pointX: " + point_X);
                point_Y = RndNumGen.Next(0, height);
                //Console.WriteLine("pointY: " + point_Y);
                temp_point = new Point(point_X, point_Y);
                points[i] = temp_point;
            }
        }
        //FUNCTION: GenerateColor
        //PURPOSE: The function GenerateColor will randomly generate values within the specified range [0-255] to represent ALPHA, RED, GREEN, BLUE (color) values
        public void GenerateColor()
        {
            //Console.WriteLine("in GenerateColor");
            int alpha, red, green, blue;

            alpha = RndNumGen.Next(MIN_ARGB, MAX_ARGB);
            //Console.WriteLine("a:" + alpha);
            red = RndNumGen.Next(MIN_ARGB, MAX_ARGB);
            //Console.WriteLine("r:" + red);
            green = RndNumGen.Next(MIN_ARGB, MAX_ARGB);
            //Console.WriteLine("g:" + green);
            blue = RndNumGen.Next(MIN_ARGB, MAX_ARGB);
            //Console.WriteLine("b:" + blue);
            Color = Color.FromArgb(alpha, red, green, blue);

        }
    }
}
