I have been trying to get a simple linear equation to draw. I can draw the axis fine but the equation will not draw. I think one would need a save/refresh function(s), but I don't know how to go about doing this:
pw = pictureBox1.Size.Width;
ph = pictureBox1.Size.Height;
w = pictureBox1.Size.Width / 2;
h = pictureBox1.Size.Height / 2;
Graphics objGraphics = this.pictureBox1.CreateGraphics();
Pen pen = new Pen(Color.Black);
b = 2;
m = 2;
for (x = 0; x < 426; x++)
{
y = m * x + b;
x = (y - b) / m;
objGraphics.DrawLine(pen, x, y, x, y);
System.Drawing.Drawing2D.GraphicsState graph = objGraphics.Save();
objGraphics.Restore(graph);
}
objGraphics.DrawLine(pen, 0, h, pw, h);
objGraphics.DrawLine(pen, w, 0, w, ph);
Thanks for any help. I should mention that I did declare all variables (x, y, m, and b). I'm just starting out with VC#, so that might explain the sloppy or simple code.