From f382d8d2fedca27ac0172ba52955e96e663eefe5 Mon Sep 17 00:00:00 2001 From: maxluli Date: Wed, 25 May 2022 11:07:35 +0200 Subject: [PATCH] Changed the drawing method of the default pencil to remove artefacts at higher widths --- Paint_2/Form1.cs | 2 +- Paint_2/Pencil.cs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Paint_2/Form1.cs b/Paint_2/Form1.cs index b5b0b53..7a49b1e 100644 --- a/Paint_2/Form1.cs +++ b/Paint_2/Form1.cs @@ -39,7 +39,7 @@ namespace Paint_2 private void canvas_MouseDown(object sender, MouseEventArgs e) { drawing = true; - sketch.StartDrawing(MousePositionToCanvasPosition(), Color.FromArgb(rnd.Next(0,256), rnd.Next(0, 256), rnd.Next(0, 256)), 5); + sketch.StartDrawing(MousePositionToCanvasPosition(), Color.FromArgb(rnd.Next(0,256), rnd.Next(0, 256), rnd.Next(0, 256)), (int)nupPencilWidth.Value); tmrRefresh.Enabled = true; //new Thread((sketch) => { (sketch as Sketch).AddDrawingPoint(this.PointToClient(MousePosition)); }).Start(); diff --git a/Paint_2/Pencil.cs b/Paint_2/Pencil.cs index 7e09cbf..c8a5adc 100644 --- a/Paint_2/Pencil.cs +++ b/Paint_2/Pencil.cs @@ -33,6 +33,8 @@ namespace Paint_2 { Graphics gr = Graphics.FromImage(canvas); int drawingCounter = 0; + Size pointSize; + foreach (List drawing in Drawings) { int pointCounter = 0; @@ -40,6 +42,8 @@ namespace Paint_2 { if (pointCounter > 0) { + pointSize = new Size(Widths[drawingCounter], Widths[drawingCounter]); + gr.FillEllipse(new SolidBrush(Colors[drawingCounter]),new Rectangle(new Point(p.X - pointSize.Width/2,p.Y - pointSize.Height/2), pointSize)); gr.DrawLine(new Pen(Colors[drawingCounter],Widths[drawingCounter]),drawing[pointCounter -1],p); }