0

I'm trying to make a simple paint application. I've tried multiple solution but nothing has worked so far. Instead of drawing smooth lines i get these kind of "dotted" lines.

Image of my problem

public void panel1_MouseMove(object sender, MouseEventArgs e)
{
    if (startPaint)
    {
        Pen p = new Pen(color, float.Parse(s));
        g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
        g.DrawLine(p, new Point(initX ?? e.X, initY ?? e.Y), new Point(e.X, e.Y));
        initX = e.X;
        initY = e.Y;
    }
}
Diado
  • 2,229
  • 3
  • 18
  • 21
  • 1
    Welcome to StackoverFlow. Please [take the tour](https://stackoverflow.com/tour), read about [how to ask good questions](https://stackoverflow.com/help/how-to-ask) and learn about [how to create a Minimal, Complete and Verifiable Example](https://stackoverflow.com/help/mcve). – Gaurang Dave Apr 12 '18 at 08:53
  • You need to set some more Pen properties. Look into MiterLimit. Set it to <1/2 pen width! Other than that you should read up on basic graphics..: 1) you leak your pen 2) mulitple lines should be drawn with DrawLines c) so you should collect the points. d) you should not cache a Graphics object....... – TaW Apr 12 '18 at 08:53
  • Wrt graphics basics See [here](https://stackoverflow.com/questions/38414334/how-to-draw-an-updating-line/38419518?s=18|19.5756#38419518) for an example of freehand drawing a line.. You still would have to do: `using (Pen p = new Pen(color, width) {MiterLimit=width/2f});) {...` – TaW Apr 12 '18 at 09:02
  • And [here is a small doodle](https://stackoverflow.com/questions/26936109/how-do-i-save-a-winforms-panels-drawing-content-to-a-file/26938635#26938635) example.. – TaW Apr 12 '18 at 09:14
  • Thank you, sir :) – 3121kasper Apr 12 '18 at 09:17

0 Answers0