public override void WidthLine()
        {
            ILineWidth lineWidth   = new LineWidth();
            int        x0          = _startPoint.X;
            int        y0          = _startPoint.Y;
            int        x1          = _endPoint.X;
            int        y1          = _endPoint.Y;
            double     angleRadian = 60 * Math.PI / 180;
            //Находим вторую пару координат линии, которую мы разворачиваем на 60 градусов.
            int x2 = (int)((x0 - x1) * Math.Cos(angleRadian) - (y0 - y1) * Math.Sin(angleRadian) + x1);
            int y2 = (int)((x0 - x1) * Math.Sin(angleRadian) + (y0 - y1) * Math.Cos(angleRadian) + y1);

            List <Point> listPoint = new List <Point>();

            lineWidth.LWidth(new Point(x0, y0), new Point(x1, y1), _linewWidth, _colorLine);
            lineWidth.LWidth(new Point(x1, y1), new Point(x2, y2), _linewWidth, _colorLine);
            lineWidth.LWidth(new Point(x2, y2), new Point(x0, y0), _linewWidth, _colorLine);

            double lengthSize1 = Math.Sqrt(Math.Pow((x1 - x0), 2) + Math.Pow((y1 - y0), 2));
            double lengthSize2 = Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2));
            double lengthSize3 = Math.Sqrt(Math.Pow((x0 - x2), 2) + Math.Pow((y0 - y2), 2));

            _centerPoint.X = (int)((lengthSize1 * x2 + lengthSize2 * x0 + lengthSize3 * x1) / (lengthSize1 + lengthSize2 + lengthSize3));
            _centerPoint.Y = (int)((lengthSize1 * y2 + lengthSize2 * y0 + lengthSize3 * y1) / (lengthSize1 + lengthSize2 + lengthSize3));
            _centerPoint   = new Point(_centerPoint.X, _centerPoint.Y);
        }
Beispiel #2
0
        public override void WidthLine()
        {
            ILineWidth lineWidth = new LineWidth();

            _centerPoint = _startPoint;
            int X0    = _startPoint.X;
            int Y0    = _startPoint.Y;
            int x     = 0;
            int y     = (int)R;
            int delta = 1 - 2 * (int)R;
            int error;

            while (y >= 0)
            {
                lineWidth.LWidth(new Point(X0 + x, Y0 + y), new Point(X0 + x, Y0 + y), _linewWidth, _colorLine);
                lineWidth.LWidth(new Point(X0 + x, Y0 - y), new Point(X0 + x, Y0 - y), _linewWidth, _colorLine);
                lineWidth.LWidth(new Point(X0 - x, Y0 + y), new Point(X0 - x, Y0 + y), _linewWidth, _colorLine);
                lineWidth.LWidth(new Point(X0 - x, Y0 - y), new Point(X0 - x, Y0 - y), _linewWidth, _colorLine);

                error = 2 * (delta + y) - 1;
                if ((delta < 0) && (error <= 0))
                {
                    delta += 2 * ++x + 1;
                    continue;
                }
                if ((delta > 0) && (error > 0))
                {
                    delta -= 2 * --y + 1;
                    continue;
                }
                delta += 2 * (++x - --y);
            }
        }
        public override void WidthLine()
        {
            ILineWidth lineWidth = new LineWidth();

            int X0 = _startPoint.X;
            int Y0 = _startPoint.Y;
            int X1 = _endPoint.X;
            int Y1 = _endPoint.Y;

            lineWidth.LWidth(new Point(X0, Y0), new Point(X1, Y0), _linewWidth, _colorLine);
            lineWidth.LWidth(new Point(X1, Y0), new Point(X1, Y1), _linewWidth, _colorLine);
            lineWidth.LWidth(new Point(X1, Y1), new Point(X0, Y1), _linewWidth, _colorLine);
            lineWidth.LWidth(new Point(X0, Y1), new Point(X0, Y0), _linewWidth, _colorLine);

            _centerPoint = new Point(X0 + ((X1 - X0) / 2), Y0 + ((Y1 - Y0) / 2));
        }
        public override void Rotate()
        {
            ConnectPoints cp        = new ConnectPoints();
            ILineWidth    lineWidth = new LineWidth();

            int          x0        = _startPoint.X;
            int          y0        = _startPoint.Y;
            int          x1        = _endPoint.X;
            int          y1        = _endPoint.Y;
            List <Point> listPoint = new List <Point>();

            double lengthSize1 = Math.Sqrt(Math.Pow((x1 - x0), 2) + Math.Pow((y1 - y0), 2));
            double lengthSize2 = Math.Sqrt(Math.Pow((x0 - x1), 2) + Math.Pow((y1 - y1), 2));
            double lengthSize3 = Math.Sqrt(Math.Pow((x0 - x0), 2) + Math.Pow((y0 - y1), 2));


            double tmpX = (x0 - node3.X) * Math.Cos(_angle) - (y0 - node3.Y) * Math.Sin(_angle) + node3.X;
            double tmpY = (x0 - node3.X) * Math.Sin(_angle) + (y0 - node3.Y) * Math.Cos(_angle) + node3.Y;

            x0 = (int)tmpX;
            y0 = (int)tmpY;

            tmpX = (x1 - node3.X) * Math.Cos(_angle) - (y1 - node3.Y) * Math.Sin(_angle) + node3.X;
            tmpY = (x1 - node3.X) * Math.Sin(_angle) + (y1 - node3.Y) * Math.Cos(_angle) + node3.Y;
            x1   = (int)tmpX;
            y1   = (int)tmpY;

            List <Point> listpoint = new List <Point>();

            listPoint.AddRange(cp.ConnectTwoPoints(new Point(x0, y0), new Point(x1, y1)));
            listPoint.AddRange(cp.ConnectTwoPoints(new Point(x1, y1), new Point(node3.X, node3.Y)));
            listPoint.AddRange(cp.ConnectTwoPoints(new Point(node3.X, node3.Y), new Point(x0, y0)));

            lineWidth.LWidth(new Point(x0, y0), new Point(x1, y1), _linewWidth, _colorLine);
            lineWidth.LWidth(new Point(x1, y1), new Point(node3.X, node3.Y), _linewWidth, _colorLine);
            lineWidth.LWidth(new Point(node3.X, node3.Y), new Point(x0, y0), _linewWidth, _colorLine);
            _centerPoint.X = (int)((lengthSize1 * x0 + lengthSize2 * node3.X + lengthSize3 * x1) / (lengthSize1 + lengthSize2 + lengthSize3));
            _centerPoint.Y = (int)((lengthSize1 * y1 + lengthSize2 * node3.Y + lengthSize3 * y1) / (lengthSize1 + lengthSize2 + lengthSize3));
            _centerPoint   = new Point(_centerPoint.X, _centerPoint.Y);
            _startPoint.X  = x0;
            _startPoint.Y  = y0;
            _endPoint.X    = x1;
            _endPoint.Y    = y1;
        }
        public override void WidthLine()
        {
            ILineWidth   lineWidth = new LineWidth();
            int          x0        = _startPoint.X;
            int          y0        = _startPoint.Y;
            int          x1        = _endPoint.X;
            int          y1        = _endPoint.Y;
            List <Point> listPoint = new List <Point>();

            lineWidth.LWidth(new Point(x0, y0), new Point(x1, y1), _linewWidth, _colorLine);
            lineWidth.LWidth(new Point(x1, y1), new Point(x0, y1), _linewWidth, _colorLine);
            lineWidth.LWidth(new Point(x0, y1), new Point(x0, y0), _linewWidth, _colorLine);

            double lengthSize1 = Math.Sqrt(Math.Pow((x1 - x0), 2) + Math.Pow((y1 - y0), 2));
            double lengthSize2 = Math.Sqrt(Math.Pow((x0 - x1), 2) + Math.Pow((y1 - y1), 2));
            double lengthSize3 = Math.Sqrt(Math.Pow((x0 - x0), 2) + Math.Pow((y0 - y1), 2));

            _centerPoint.X = (int)((lengthSize1 * x0 + lengthSize2 * x0 + lengthSize3 * x1) / (lengthSize1 + lengthSize2 + lengthSize3));
            _centerPoint.Y = (int)((lengthSize1 * y1 + lengthSize2 * y0 + lengthSize3 * y1) / (lengthSize1 + lengthSize2 + lengthSize3));
            _centerPoint   = new Point(_centerPoint.X, _centerPoint.Y);
        }
        public override void WidthLine()
        {
            ILineWidth lineWidth = new LineWidth();

            _centerPoint = _startPoint;
            RX           = Math.Sqrt(Math.Pow((_endPoint.X - _startPoint.X), 2));
            RY           = Math.Sqrt(Math.Pow((_endPoint.Y - _startPoint.Y), 2));

            int centerX = _startPoint.X;
            int centerY = _startPoint.Y;
            int radiusX = (int)RX;
            int radiusY = (int)RY;

            int posX = radiusX;
            int posY = 0;

            int deltaX = 2 * radiusY * radiusY * posX;
            int deltaY = 2 * radiusX * radiusX * posY;
            int err    = (radiusX * radiusX) - (radiusY * radiusY * radiusX) + (radiusY * radiusY) / 4;

            while (deltaY < deltaX)
            {
                lineWidth.LWidth(new Point(centerX + posX, centerY + posY), new Point(centerX + posX, centerY + posY), _linewWidth, _colorLine);
                lineWidth.LWidth(new Point(centerX + posX, centerY - posY), new Point(centerX + posX, centerY - posY), _linewWidth, _colorLine);
                lineWidth.LWidth(new Point(centerX - posX, centerY + posY), new Point(centerX - posX, centerY + posY), _linewWidth, _colorLine);
                lineWidth.LWidth(new Point(centerX - posX, centerY - posY), new Point(centerX - posX, centerY - posY), _linewWidth, _colorLine);
                posY++;

                if (err < 0)
                {
                    deltaY += 2 * radiusX * radiusX;
                    err    += deltaY + radiusX * radiusX;
                }
                else
                {
                    posX--;
                    deltaY += 2 * radiusX * radiusX;
                    deltaX -= 2 * radiusY * radiusY;
                    err    += deltaY - deltaX + radiusX * radiusX;
                }
            }

            err = radiusX * radiusX * (posY * posY + posY)
                  + radiusY * radiusY * (posX - 1) * (posX - 1)
                  - radiusY * radiusY * radiusX * radiusX;

            while (posX >= 0)
            {
                lineWidth.LWidth(new Point(centerX + posX, centerY + posY), new Point(centerX + posX, centerY + posY), _linewWidth, _colorLine);
                lineWidth.LWidth(new Point(centerX + posX, centerY - posY), new Point(centerX + posX, centerY - posY), _linewWidth, _colorLine);
                lineWidth.LWidth(new Point(centerX - posX, centerY + posY), new Point(centerX - posX, centerY + posY), _linewWidth, _colorLine);
                lineWidth.LWidth(new Point(centerX - posX, centerY - posY), new Point(centerX - posX, centerY - posY), _linewWidth, _colorLine);
                posX--;

                if (err > 0)
                {
                    deltaX -= 2 * radiusY * radiusY;
                    err    += radiusY * radiusY - deltaX;
                }
                else
                {
                    posY++;
                    deltaY += 2 * radiusX * radiusX;
                    deltaX -= 2 * radiusY * radiusY;
                    err    += deltaY - deltaX + radiusY * radiusY;
                }
            }
        }
        public override void WidthLine()
        {
            ILineWidth lineWidth = new LineWidth();

            Point        oneP  = _startPoint;
            Point        twoP  = _startPoint;
            Point        threP = _startPoint;
            Point        fourP = _startPoint;
            int          d;
            List <Point> listPoint = new List <Point>();

            if (_startPoint.X < _endPoint.X && _startPoint.Y < _endPoint.Y)
            {
                d      = _endPoint.Y - _startPoint.Y;
                twoP.X = _startPoint.X + d;
                twoP.Y = _startPoint.Y;

                threP.X = twoP.X;
                threP.Y = threP.Y + d;

                fourP.X = threP.X - d;
                fourP.Y = threP.Y;

                _centerPoint = new Point(_startPoint.X + ((_endPoint.X - _startPoint.X) / 2), _startPoint.Y + ((_endPoint.Y - _startPoint.Y) / 2));
            }
            if (_startPoint.X > _endPoint.X && _startPoint.Y > _endPoint.Y)
            {
                d      = _startPoint.X - _endPoint.X;
                twoP.X = _startPoint.X - d;
                twoP.Y = _startPoint.Y;

                threP.X = twoP.X;
                threP.Y = threP.Y - d;

                fourP.X = threP.X + d;
                fourP.Y = threP.Y;

                _centerPoint = new Point(_endPoint.X + ((_startPoint.X - _endPoint.X) / 2), _endPoint.Y + ((_startPoint.Y - _endPoint.Y) / 2));
            }
            if (_startPoint.X > _endPoint.X && _startPoint.Y < _endPoint.Y)
            {
                d      = _startPoint.X - _endPoint.X;
                twoP.X = _startPoint.X;
                twoP.Y = _startPoint.Y + d;

                threP.X = twoP.X - d;
                threP.Y = twoP.Y;

                fourP.X = threP.X;
                fourP.Y = threP.Y - d;

                _centerPoint = new Point(_endPoint.X + ((_startPoint.X - _endPoint.X) / 2), _startPoint.Y + ((_endPoint.Y - _startPoint.Y) / 2));
            }
            if (_startPoint.X < _endPoint.X && _startPoint.Y > _endPoint.Y)
            {
                d      = _endPoint.X - _startPoint.X;
                twoP.X = _startPoint.X + d;
                twoP.Y = _startPoint.Y;

                threP.X = twoP.X;
                threP.Y = threP.Y - d;

                fourP.X = threP.X - d;
                fourP.Y = threP.Y;

                _centerPoint = new Point(_startPoint.X + ((_endPoint.X - _startPoint.X) / 2), _endPoint.Y + ((_startPoint.Y - _endPoint.Y) / 2));
            }
            lineWidth.LWidth(new Point(_startPoint.X, _startPoint.Y), new Point(twoP.X, twoP.Y), _linewWidth, _colorLine);
            lineWidth.LWidth(new Point(twoP.X, twoP.Y), new Point(threP.X, threP.Y), _linewWidth, _colorLine);
            lineWidth.LWidth(new Point(threP.X, threP.Y), new Point(fourP.X, fourP.Y), _linewWidth, _colorLine);
            lineWidth.LWidth(new Point(fourP.X, fourP.Y), new Point(_startPoint.X, _startPoint.Y), _linewWidth, _colorLine);
        }
Beispiel #8
0
        public override void WidthLine()
        {
            ILineWidth lineWidth = new LineWidth();

            lineWidth.LWidth(_startPoint, _endPoint, _linewWidth, _colorLine);
        }