コード例 #1
0
        public override List <Point> GetPoints()
        {
            ConnectPoints cp = new ConnectPoints();

            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>();

            listPoint.AddRange(cp.ConnectTwoPoints(new Point(x0, y0), new Point(x1, y1)));
            listPoint.AddRange(cp.ConnectTwoPoints(new Point(x1, y1), new Point(x2, y2)));
            listPoint.AddRange(cp.ConnectTwoPoints(new Point(x2, y2), new Point(x0, y0)));

            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);

            return(listPoint);
        }
コード例 #2
0
        public override List <Point> GetPoints()
        {
            ConnectPoints cp = new ConnectPoints();

            int x0 = _startPoint.X;
            int y0 = _startPoint.Y;
            int x1 = _endPoint.X;
            int y1 = _endPoint.Y;
            //node3.X = _startPoint.X;
            //node3.Y = _endPoint.Y;
            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)));

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

            _centerPoint.X = (int)((lengthSize1 * node3.X + lengthSize2 * x0 + lengthSize3 * x1) / (lengthSize1 + lengthSize2 + lengthSize3));
            _centerPoint.Y = (int)((lengthSize1 * node3.Y + lengthSize2 * y0 + lengthSize3 * y1) / (lengthSize1 + lengthSize2 + lengthSize3));


            return(listPoint);
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        public override List <Point> GetPoints()
        {
            ConnectPoints cp = new ConnectPoints();

            int          X0         = _startPoint.X;
            int          Y0         = _startPoint.Y;
            int          X1         = _endPoint.X;
            int          Y1         = _endPoint.Y;
            List <Point> listPoints = new List <Point>();

            listPoints.AddRange(cp.ConnectTwoPoints(new Point(X0, Y0), new Point(X1, Y0)));
            listPoints.AddRange(cp.ConnectTwoPoints(new Point(X1, Y0), new Point(X1, Y1)));
            listPoints.AddRange(cp.ConnectTwoPoints(new Point(X1, Y1), new Point(X0, Y1)));
            listPoints.AddRange(cp.ConnectTwoPoints(new Point(X0, Y1), new Point(X0, Y0)));


            _centerPoint = new Point(X0 + ((X1 - X0) / 2), Y0 + ((Y1 - Y0) / 2));
            return(listPoints);
        }
コード例 #5
0
        public override void Fill(Point mouse, Color fillColor, Color colorLine)
        {
            Color beginColor = sBitmap._fillBitmap.GetPixel(mouse.X, mouse.Y);
            Point left       = new Point(mouse.X, mouse.Y);
            Point right      = new Point(mouse.X, mouse.Y);

            while (left.X - 1 > 0 && sBitmap._fillBitmap.GetPixel(left.X - 1, left.Y) == beginColor)
            {
                left.X--;
            }
            while (right.X + 1 <= sBitmap._fillBitmap.Width - 1 && sBitmap._fillBitmap.GetPixel(right.X + 1, right.Y) == beginColor)
            {
                right.X++;
            }

            List <Point> linePoints = cp.ConnectTwoPoints(left, right);

            sBitmap.Draw(linePoints, fillColor);

            if (mouse.Y > 0 && mouse.Y < sBitmap._fillBitmap.Height - 1 && mouse.X > 0 && mouse.X < sBitmap._fillBitmap.Width - 1)
            {
                for (int i = left.X; i <= right.X; i++)
                {
                    if (sBitmap._fillBitmap.GetPixel(i, mouse.Y + 1) == beginColor && sBitmap._fillBitmap.GetPixel(i, mouse.Y + 1) != colorLine)
                    {
                        Point down = new Point(i, mouse.Y + 1);
                        Fill(down, fillColor, colorLine);
                    }

                    if (sBitmap._fillBitmap.GetPixel(i, mouse.Y - 1) == beginColor && sBitmap._fillBitmap.GetPixel(i, mouse.Y - 1) != colorLine)
                    {
                        Point up = new Point(i, mouse.Y - 1);
                        Fill(up, fillColor, colorLine);
                    }
                }
            }
            else
            {
                return;
            }


            //if (mouse.Y > 0 && mouse.Y < sBitmap._fillBitmap.Height && mouse.X > 0 && mouse.X < sBitmap._fillBitmap.Width)
            //{
            //    Color beginColor = sBitmap._fillBitmap.GetPixel(mouse.X, mouse.Y);
            //    Point left = new Point(mouse.X, mouse.Y);
            //    Point right = new Point(mouse.X, mouse.Y);

            //    //находим конечные точки влево и вправо
            //    while (sBitmap._fillBitmap.GetPixel(left.X - 1, left.Y) == beginColor && left.X - 1 > 0 && left.X < sBitmap._fillBitmap.Width)
            //    {
            //        left.X--;
            //    }
            //    while (sBitmap._fillBitmap.GetPixel(right.X + 1, right.Y) == beginColor && right.X > 0 && right.X - 1 < sBitmap._fillBitmap.Width)
            //    {
            //        right.X++;
            //    }

            //    List<Point> linePoints = cp.ConnectTwoPoints(left, right);
            //    sBitmap.Draw(linePoints, fillColor);

            //    if (mouse.Y > 0 && mouse.Y < sBitmap._fillBitmap.Height && mouse.X > 0 && mouse.X < sBitmap._fillBitmap.Width)
            //    {
            //        for (int i = left.X; i <= right.X; i++)
            //        {
            //            if (sBitmap._fillBitmap.GetPixel(i, mouse.Y + 1) == beginColor)
            //            {
            //                Point down = new Point(i, mouse.Y + 1);
            //                Fill(down, fillColor);
            //            }

            //            if (sBitmap._fillBitmap.GetPixel(i, mouse.Y - 1) == beginColor)
            //            {
            //                Point up = new Point(i, mouse.Y - 1);
            //                Fill(up, fillColor);
            //            }
            //        }
            //    }
            //    else
            //    {
            //        return;
            //    }
            //}
            //else
            //{
            //    return;
            //}
        }
コード例 #6
0
        public override List <Point> GetPoints()
        {
            ConnectPoints cp = new ConnectPoints();

            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));
            }
            listPoint.AddRange(cp.ConnectTwoPoints(new Point(_startPoint.X, _startPoint.Y), new Point(twoP.X, twoP.Y)));
            listPoint.AddRange(cp.ConnectTwoPoints(new Point(twoP.X, twoP.Y), new Point(threP.X, threP.Y)));
            listPoint.AddRange(cp.ConnectTwoPoints(new Point(threP.X, threP.Y), new Point(fourP.X, fourP.Y)));
            listPoint.AddRange(cp.ConnectTwoPoints(new Point(fourP.X, fourP.Y), new Point(_startPoint.X, _startPoint.Y)));

            return(listPoint);
        }
コード例 #7
0
        public override List <Point> GetPoints()
        {
            ConnectPoints cp = new ConnectPoints();

            return(cp.ConnectTwoPoints(_startPoint, _endPoint));
        }