Xét đoạn mã sau từ một tiêu chuẩn System.Windows.Forms.Form
LinearGradientBrush không làm đúng
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);
}
}
Nó tạo ra kết quả này:
Tại sao các đường màu đỏ và màu xanh hiển thị theo thứ tự không chính xác và điều này có thể được khắc phục như thế nào?