Ejemplo n.º 1
0
 public Boolean CheckWidth(int maxWidth, int SizeChange, Point[] point, Sizes sizes)
 {
     SizeChange = SizeChange + sizes.OFFSET;
     if ((point[0].X + SizeChange > maxWidth))
     {
         return false;
     }
     else if ((point[1].X + SizeChange > maxWidth))
     {
         return false;
     }
     else if ((point[2].X + SizeChange > maxWidth))
     {
         return false;
     }
     return true;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// I'm not exactly sure the use of this??
        /// All it does is create create a file 
        /// </summary>
        /// <param name="size"></param>
        public void RandomShape(Sizes size)
        {
            Random ran = new Random();

            int Max_Height = size.Window_Height;
            int max_Width = size.Window_Width;
            int offset = size.OFFSET;

            using (ReadWriteCsv.CsvFileWriter writer = new ReadWriteCsv.CsvFileWriter("Shape.csv"))
            {
                ReadWriteCsv.CsvRow row = new ReadWriteCsv.CsvRow();
                int numberOfShapes = ran.Next(15);

                for (int i = 0; i < numberOfShapes; i++)
                {
                    row.Add(ran.Next(max_Width).ToString());
                    row.Add(ran.Next(Max_Height).ToString());

                    writer.WriteRow(row);
                    row.Clear();
                }

            }
        }
Ejemplo n.º 3
0
        public List<Shapes> DrawHexagon(Graphics g, List<Shapes> shapeList, int Width, int Height, Sizes sizes, int[] numbers, String[] shapes)
        {
            // Honeycomb effect

            //Need to use 3 points and then drawPolygon
            Point[] point = new Point[6];
            shapeList = new List<Shapes>();
            Shapes hexagon;
            int[] xArray = new int[6];
            int[] yArray = new int[6];
            Boolean upperHexagon = false;

            Pen myPen = new Pen(System.Drawing.Color.Black, 1);

            //Left most point to resume drawing at the level below
            Point leftMostPoint = new Point();

            //Set up general parameters
            int offset = sizes.OFFSET;
            int maxWidth = Width - offset;
            int maxHeight = Height - offset - sizes.STATUS_BAR;

            int sliderModifier = numbers[4];
            int constant = 39; // This makes the hexagons bigger. seem to be more reliable
            int sizeChange = numbers[2] + sliderModifier + constant;
            int height = coordinateGeometry.Pythagoras(sizeChange, (sizeChange / 2));
            //Draw first hexagon
            point[0].X = offset;
            point[0].Y = offset + sizeChange;

            leftMostPoint = point[0];

            do
            {
                do
                {
                    point = CalculatePointsHexagon(point, sizeChange, height);

                    xArray = FillXArray(point, xArray);
                    yArray = FillYArray(point, yArray);

                    //Creats a hexagon shape
                    hexagon = shapeFactory.getShape(shapes[0]);
                    hexagon.setPoints(xArray, yArray);

                    shapeList.Add(hexagon);

                    g.DrawPolygon(myPen, point);

                    //Depending on boolean either draws from point 2 or 4
                    if (upperHexagon)
                    {
                        point[0].X = point[2].X;
                        point[0].Y = point[2].Y;
                    }
                    else
                    {
                        point[0].X = point[4].X;
                        point[0].Y = point[4].Y;
                    }
                    upperHexagon = FlipBoolean(upperHexagon);
                } while ((point[3].X + (sizeChange * 2)) < maxWidth);

                //Uses the leftmost point to reset the line back to left and moves the object down
                point[0] = leftMostPoint;
                point[0].Y = point[0].Y + height * 2;
                leftMostPoint = point[0];
                upperHexagon = false;

            } while ((point[5].Y + (sizeChange * 2) + offset) < maxHeight);

            return shapeList;
        }
Ejemplo n.º 4
0
        public List<Shapes> DrawTriangle(Graphics g, List<Shapes> shapeList, int Width, int Height, Sizes sizes, int[] numbers, String[] shapes)
        {
            General general = new General();
            shapeList = new List<Shapes>();
            Shapes triangle;
            int[] xArray = new int[3];
            int[] yArray = new int[3];

            Pen myPen = new Pen(System.Drawing.Color.Black, 1);

            //Left most point to resume drawing at the level below
            Point leftMostPoint = new Point();

            //Set up general parameters
            int offset = sizes.OFFSET;
            int maxWidth = Width;
            int maxHeight = Height - sizes.STATUS_BAR - offset;

            int sliderModifier = numbers[4];

            int SizeChange = numbers[2] + sliderModifier;
            int pythagHeight = coordinateGeometry.Pythagoras(SizeChange, (SizeChange / 2));

            //first enum value
            MovingPointTriangle value = MovingPointTriangle.Point0;

            //Downward facing triangle first so you know the point will always be in the form then
            //Need to use 3 points and then drawPolygon
            //Draw the inital triangle, special case
            Point[] point = new Point[3];
            point[0].X = offset;
            point[0].Y = offset;

            point[1].X = offset + SizeChange / 2;
            point[1].Y = offset + pythagHeight;

            point[2].X = offset + SizeChange;
            point[2].Y = offset;

            Boolean up = false;
            Boolean upOuter = false;

            do
            {

                leftMostPoint = coordinateGeometry.CheckForLowestPoint(point);
                g.DrawPolygon(myPen, point);

                //Create shape object for triangle
                xArray = FillXArray(point, xArray);
                yArray = FillYArray(point, yArray);

                triangle = shapeFactory.getShape(shapes[0]);
                triangle.setPoints(xArray, yArray);

                shapeList.Add(triangle);

                do
                {
                    switch (value)
                    {
                        case MovingPointTriangle.Point0:

                            point[0] = coordinateGeometry.TriangleModifier(up, point[0], SizeChange, pythagHeight);
                            up = FlipBoolean(up);
                            value = MovingPointTriangle.Point1;

                            break;
                        case MovingPointTriangle.Point1:

                            point[1] = coordinateGeometry.TriangleModifier(up, point[1], SizeChange, pythagHeight);
                            up = FlipBoolean(up);
                            value = MovingPointTriangle.Point2;

                            break;
                        case MovingPointTriangle.Point2:
                            point[2] = coordinateGeometry.TriangleModifier(up, point[2], SizeChange, pythagHeight);
                            up = FlipBoolean(up);
                            value = MovingPointTriangle.Point0;

                            break;
                    }

                    g.DrawPolygon(myPen, point);
                    xArray = FillXArray(point, xArray);
                    yArray = FillYArray(point, yArray);

                    triangle = shapeFactory.getShape(shapes[0]);
                    triangle.setPoints(xArray, yArray);
                    shapeList.Add(triangle);
                } while (general.CheckWidth(maxWidth, SizeChange, point, sizes));

                value = MovingPointTriangle.Point0;

                if (upOuter)
                {
                    point = coordinateGeometry.PointingDownwardsTriangle(point, leftMostPoint, pythagHeight, SizeChange, offset);

                    up = false;
                }
                else
                {
                    point = coordinateGeometry.PointingUpwardsTriangle(point, leftMostPoint, pythagHeight, SizeChange);

                    up = true;
                }
                upOuter = FlipBoolean(upOuter);
            } while (general.CheckHeight(maxHeight, SizeChange, point));

            return shapeList;
        }
Ejemplo n.º 5
0
        public List<Shapes> DrawSquare(Graphics g, List<Shapes> shapeList, int Width, int Height, Sizes sizes, int[] numbers, String[] shapes)
        {
            Pen myPen = new Pen(System.Drawing.Color.Black, 1);

            shapeList = new List<Shapes>();

            int maxWidth = Width;
            int maxHeight = Height;
            Shapes square;
            int[] xArray = new int[2];
            int[] yArray = new int[2];

            maxWidth = maxWidth - sizes.OFFSET;
            maxHeight = maxHeight - sizes.OFFSET - sizes.OFFSET - sizes.STATUS_BAR;

            int x = sizes.OFFSET;
            int xOld = sizes.OFFSET;
            int y = sizes.OFFSET;
            int yOld = sizes.OFFSET;

            int sliderModifier = numbers[4];
            //Logger.Debug("Slider size = " + numbers[4]);

            int SizeChange = numbers[2] + sliderModifier;

            int iteration = 0;
            do
            {

                Rectangle myRectangle = new Rectangle(x, y, SizeChange, SizeChange);
                g.DrawRectangle(myPen, myRectangle);
                xArray[0] = x;
                xArray[1] = x + SizeChange;
                do
                {
                    Rectangle myRectangle2 = new Rectangle(x, y, SizeChange, SizeChange);
                    g.DrawRectangle(myPen, myRectangle2);

                    square = shapeFactory.getShape(shapes[0]);

                    yArray[0] = y;
                    yArray[1] = y + SizeChange;
                    square.setPoints(xArray, yArray);
                    shapeList.Add(square);

                    y = y + SizeChange;
                } while (y + SizeChange < maxHeight);
                iteration++;

                y = sizes.OFFSET;
                x = x + SizeChange;
                if (x + SizeChange > maxWidth)
                {
                    x = sizes.OFFSET + (iteration * SizeChange);
                }
            } while (x + SizeChange < maxWidth);

            return shapeList;
        }