Exemplo n.º 1
0
        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            Function17 Gi = new Function17();

            Gi.graf(pictureBox1.Width, pictureBox1.Height, (trackBar1.Value));
            pictureBox1.Image = Gi.Bitmap;
        }
Exemplo n.º 2
0
        public override void graf(int width, int height, float scale)
        {
            double x;
            double h = (B - A) / N; //0.01;

            listOfPoints = new PointF[(int)N];
            Function17 acc = new Function17();

            //MessageBox.Show(System.Convert.ToString((A)+"  "+System.Convert.ToString(B)));

            for (int i = 0; i < N; i++)
            {
                if (i == 0)
                {
                    x = A + h;
                }
                else
                if (i == N - 1)
                {
                    x = B - h;
                }
                else
                {
                    x = h * i + A;
                };
                listOfPoints[i] = new PointF((float)x, vich(x));
            }

            bitmap = new Bitmap(width, height);
            Graphics g = Graphics.FromImage(bitmap);

            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            Pen p = new Pen(Color.Black, 2);

            for (int i = 0; i < listOfPoints.Length; i++)
            {
                listOfPoints[i].X = listOfPoints[i].X * scale + width / 2;
                listOfPoints[i].Y = height / 2 - listOfPoints[i].Y * scale;
            }
            g.DrawLines(p, listOfPoints);
            g.DrawLine(p, width / 2, 0, width / 2, height);
            for (int i = 10; i > -8; i--)
            {
                Font drawFont = new Font("Arial", 14);
                if (i < 0)
                {
                    g.DrawString(System.Convert.ToString(i), drawFont, Brushes.Red, height / 2 + (i * scale - 12), 235);
                }
                else if (i > 0)
                {
                    g.DrawString(System.Convert.ToString(i), drawFont, Brushes.Red, height / 2 + (i * scale - 8), 235);
                }
            }
            for (int i = -8; i < 10; i++)
            {
                Font drawFont = new Font("Arial", 14);
                if (i < 0)
                {
                    g.DrawString(System.Convert.ToString(i), drawFont, Brushes.Red, 233, height / 2 - (i * scale + 13));
                }
                else if (i > 0)
                {
                    g.DrawString(System.Convert.ToString(i), drawFont, Brushes.Red, 235, height / 2 - (i * scale + 14));
                }
            }
            for (int i = -8; i < 10; i++)
            {
                float y = height / 2 - i * scale;
                g.DrawLine(p, 215, y, 225, y);
            }
            for (int i = -8; i < 10; i++)
            {
                float x1 = width / 2 - i * scale;
                g.DrawLine(p, x1, 215, x1, 225);
            }
            g.DrawLine(p, 0, height / 2, width, height / 2);
        }