Beispiel #1
0
        public void DrawFigure(IFormFigure formFigure, Bitmap newBitmap, Point p1, PictureBox pictureBox)
        {
            List <Point> figurePoints = formFigure.CalculateFigure(startPoint, p1);

            if (formFigure is CircleForm || formFigure is EllipseForm)
            {
                for (int i = 0; i < figurePoints.Count - 1; i++)
                {
                    brush.DrawLine(figurePoints[i], figurePoints[i + 1], pictureBox, brush.currentColor, newBitmap);
                }
            }
            else
            {
                if (formFigure is CircleForm || formFigure is EllipseForm)
                {
                    for (int i = 0; i < figurePoints.Count; i++)
                    {
                        if (i != figurePoints.Count - 1)
                        {
                            brush.DrawLine(figurePoints[i], figurePoints[i + 1], pictureBox, brush.currentColor, newBitmap);
                        }
                        else
                        {
                            brush.DrawLine(figurePoints[i], figurePoints[0], pictureBox, brush.currentColor, newBitmap);
                        }
                    }
                }
            }
        }
Beispiel #2
0
 public VectorFigurePainter(Brush brush, IFormFigure formFigure, Point startPoint, AbstractFilling typeOfFilling)
 {
     this.brush         = brush;
     this.formFigure    = formFigure;
     this.startPoint    = startPoint;
     this.typeOfFilling = typeOfFilling;
     points             = formFigure.CalculateFigure(startPoint, startPoint);
 }
Beispiel #3
0
        public int[] CalculateFigureTest(int[] points)
        {
            Point p1 = new Point(points[0], points[1]),
                  p2 = new Point(points[2], points[3]);

            List <Point> currentList = figure.CalculateFigure(p1, p2);

            int[] current    = new int[currentList.Count * 2];
            int   curCounter = 0;

            for (int i = 0; i < currentList.Count; i++)
            {
                current[curCounter] = currentList[i].X;
                curCounter++;
                current[curCounter] = currentList[i].Y;
                curCounter++;
            }

            return(current);
        }
Beispiel #4
0
        public void CalculateFigureTest(int[] points)
        {
            Point p1 = new Point(points[0], points[1]),
                  p2 = new Point(points[2], points[3]);

            List <Point> currentList = figure.CalculateFigure(p1, p2);

            int[] current    = new int[currentList.Count * 2];
            int   curCounter = 0;

            for (int i = 0; i < currentList.Count; i++)
            {
                current[curCounter] = currentList[i].X;
                curCounter++;
                current[curCounter] = currentList[i].Y;
                curCounter++;
            }

            Assert.AreEqual(expectedResult, current);
        }