我想使用c#表单应用程序绘制一阶函数图吗?

时间:2018-12-02 22:44:38

标签: c# forms function graph

我想画一个一阶函数。但是我需要在同一张表中绘制一些函数。线相交的点必须标记。我为此应用程序使用了图形库。但是我没有得到真正的结果。

我想要的图像如下。

enter image description here

enter code here
enter code here
        int A = int.Parse(textBox1.Text);
        int B = int.Parse(textBox2.Text);
        var graph = new Bitmap(1000, 1000);
        var g = Graphics.FromImage(graph);

        //grid
        for (int i = 0; i < 800; i += 10)
        {
            g.DrawLine(Pens.WhiteSmoke, i, 0, i, 800);
            g.DrawLine(Pens.WhiteSmoke, 0, i, 800, i);
        }

        //eksen
        g.DrawLine(Pens.Gray, 0, 200, 420, 200);
        g.DrawLine(Pens.Gray, 200, 0, 200, 400);

        //sayılar
        for (int i = -200; i <= 200; i += 40)
        {
            g.DrawString((i / 10).ToString(), new Font(FontFamily.GenericMonospace, 10, FontStyle.Regular), Brushes.Black, i + 200, 200);
            g.DrawString((-i / 10).ToString(), new Font(FontFamily.GenericMonospace, 10, FontStyle.Regular), Brushes.Black, 200, i + 200);
        }



        for (int x = -50; x <= 50; x++)
        {
            A++;
            g.DrawEllipse(Pens.Blue, A + 200, (x + 200) - B, 1, 2);
        }


                    pictureBox1.Image = graph;

0 个答案:

没有答案