Beispiel #1
0
        //由点划线
        private void DemoDrawPoint(Graphics g)
        {
            //创建曲线中的点
            Point point0 = new Point(1, 2);
            Point point1 = new Point(30, 5);
            Point point2 = new Point(60, 10);
            Point point3 = new Point(74, 23);
            Point point4 = new Point(77, 102);
            Point point5 = new Point(80, 160);
            Point point6 = new Point(90, 180);
            Point point7 = new Point(150, 181);
            Point point8 = new Point(220, 200);

            //放到数组中
            Point[] curvePoints = { point0, point1, point2, point3, point4, point5, point6, point7, point8 };

            //使用类标准化数据
            PointF[] curvePointsF = new curveRender(curvePoints, this.pictureBox1).curvePointsF;


            //创建路径
            GraphicsPath myPath = new GraphicsPath();

            //AddCurve(点阵,起点,终点,弯曲程度)
            //myPath.AddCurve(curvePoints, 0, 7, 0.5f);//最后一个参数[0,1]越大,曲线越平滑
            //myPath.AddCurve(curvePointsF, 0, 7, 0.99f);//最后一个参数[0,1]越大,曲线越平滑
            myPath.AddCurve(curvePointsF);

            //定义铅笔
            Pen myPen  = new Pen(Color.Red, 1);
            Pen myPen2 = new Pen(Color.Blue, 2);

            //画路径
            g.DrawPath(myPen, myPath);
            //画空心圆
            g.DrawEllipse(myPen, 20, 30, 10, 10);

            //画点
            //int x = 10, y = 100;
            //g.FillEllipse(Brushes.Blue, x, y, 10, 10);
            int   pointRadius = 8;                  //点的半径
            Brush blueBrush   = Brushes.BlueViolet; //点的颜色

            foreach (PointF p in curvePointsF)
            {
                g.FillEllipse(blueBrush, p.X, p.Y, pointRadius, pointRadius);
            }
        }
Beispiel #2
0
        //由点划线
        private void DemoDrawPoint(Graphics g)
        {
            //创建曲线中的点
            Point point0 = new Point(1, 2);
            Point point1 = new Point(30, 5);
            Point point2 = new Point(60, 10);
            Point point3 = new Point(74, 23);
            Point point4 = new Point(77, 102);
            Point point5 = new Point(80, 160);
            Point point6 = new Point(90, 180);
            Point point7 = new Point(150, 181);
            Point point8 = new Point(220, 200);
            //放到数组中
            Point[] curvePoints = { point0, point1, point2, point3, point4, point5, point6, point7, point8 };

            //使用类标准化数据
            PointF[] curvePointsF = new curveRender(curvePoints, this.pictureBox1).curvePointsF;

            //创建路径
            GraphicsPath myPath = new GraphicsPath();
            //AddCurve(点阵,起点,终点,弯曲程度)
            //myPath.AddCurve(curvePoints, 0, 7, 0.5f);//最后一个参数[0,1]越大,曲线越平滑
            //myPath.AddCurve(curvePointsF, 0, 7, 0.99f);//最后一个参数[0,1]越大,曲线越平滑
            myPath.AddCurve(curvePointsF);

            //定义铅笔
            Pen myPen = new Pen(Color.Red, 1);
            Pen myPen2 = new Pen(Color.Blue, 2);

            //画路径
            g.DrawPath(myPen, myPath);
            //画空心圆
            g.DrawEllipse(myPen, 20, 30, 10, 10);

            //画点
            //int x = 10, y = 100;
            //g.FillEllipse(Brushes.Blue, x, y, 10, 10);
            int pointRadius = 8;//点的半径
            Brush blueBrush = Brushes.BlueViolet;//点的颜色
            foreach(PointF p in curvePointsF){
                g.FillEllipse(blueBrush, p.X, p.Y, pointRadius, pointRadius);
            }
        }