所以我正在製作一個繪畫應用程序,我想知道如何保留我繪製的線條的粗細。因此,我的應用程序使用繪製的所有線條的列表的列表,並在每次用戶繪製新線條時再次繪製它們。現在我遇到了一個問題,當我改變筆的大小時,所有行的大小都會改變,因爲它們都被重繪了。保留筆的大小?
我的代碼:
//Create new pen
Pen p = new Pen(Color.Black, penSize);
//Set linecaps for start and end to round
p.StartCap = LineCap.Round;
p.EndCap = LineCap.Round;
//Turn on AntiAlias
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
//For each list of line coords, draw all lines
foreach (List<Point> lstP in previousPoints)
{
e.Graphics.DrawLine(p, lstP[0], lstP[1]);
}
p.Dispose();
我知道一個可以使用Pen.Width()的循環過程中改變畫筆大小,但我怎麼能保存線寬?
你可能想研究[這篇文章關於DrawAction類](https://stackoverflow.com/questions/28714411/update-a-drawing-without-deleting-the-previous-one/28716887?s=6 | 0.1736#28716887) – TaW