On top of form1 i did:
private int pixelscounter; private int counter; private float xFactor, yFactor; List<PointF> points = new List<PointF>(); double increment = 1.25; double factor = 1.0; Image img; private Point startingPoint = Point.Empty; private Point movingPoint = Point.Empty; private bool panning = false; GraphicsPath gp = new GraphicsPath(); GraphicsPath redgp = new GraphicsPath();
In pictureBox1 move event i did:
if (checkBox2.Checked && e.Button == MouseButtons.Left) { gp.AddLine(e.X * xFactor, e.Y * yFactor, e.X * xFactor, e.Y * yFactor); pixelscounter += 1; if (pixelscounter == 10) { redgp.AddEllipse((e.X) * xFactor, (e.Y) * yFactor, 3f, 3f); pixelscounter = 0; } p = e.Location; pictureBox2.Invalidate(); }
In pictureBox2 paint event:
if (checkBox2.Checked) { using (Pen pp = new Pen(Color.Green, 2f)) { pp.StartCap = pp.EndCap = LineCap.Round; pp.LineJoin = LineJoin.Round; e.Graphics.DrawPath(pp, gp); } using (Pen pp = new Pen(Color.Red, 2f)) { pp.StartCap = pp.EndCap = LineCap.Round; pp.LineJoin = LineJoin.Round; e.Graphics.DrawPath(pp, redgp); } }
What I did is that when I click mouse left button press without leave it then drag the mouse around pictureBox1 its drawing a line in pictureBox2 in green and every 10 locations(pixels) its creating a red point automatic.
The problem is when I move the mouse fast or fast movements then the red points are not in the same distance of 10 locations(pixels) if I move the mouse very very slow the red points are too close to each other if I move the mouse regular more or less it seems that the points distance between each other are ok and if I move the mouse fast/very fast the distance between every red point is large more then 10 pixels.
How can I fix/solve this mouse movements problem ?
Can someone show me in my code the fixed code how to calculate the difference between the start and the current position. Then draw a dot for every 10 pixels in between and set the new start position on the last dot i added ?
I saw the formula but not sure how to do it in my code.