LinearGradientBrush does not render correctly
问题 Consider the following code from a standard System.Windows.Forms.Form protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Rectangle test = new Rectangle(50, 50, 100, 100); using (LinearGradientBrush brush = new LinearGradientBrush(test, Color.Red, Color.Blue, 0f)) { e.Graphics.DrawRectangle(new Pen(brush, 8), test); } } It produces this result: Why are the red and blue lines showing up in the incorrect order, and how can this be fixed? 回答1: The rendering origin is the problem