First the code
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
System.Drawing.Graphics g;
System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(Color.Blue);
g = pictureBox1.CreateGraphics();
g.FillRectangle(brush, e.X, e.Y, 5, 5);
}
This event handler would fire up whenever the mouse moves over a picture box and create a pixel. Now the problem is that as long as i move the mouse slowly all those pixels form a line. However whenever i move the mouse a bit fast the line breaks and all i see are dots with wide spaces in between them.
Need help in this matter.
When the mouse is moved, you won’t get a
MouseMoveevent for every single pixel traveled by the mouse pointer. You’ll get them at a fairly consistent time interval, so the faster the mouse moves, the further apart the points you’ll get.What you need to do is store the position of the last point received, and draw an actual line using
DrawLinebetween the old position and the new one.