如果我用LinearGradientBrush
来绘制一个宽度大于202像素的矩形,左侧会出现颜色晕染:
以下是一个宽度为202像素的矩形的代码:
private void MainForm_Paint(object sender, PaintEventArgs e)
{
Rectangle r = new Rectangle(50, 50, 202, 50);
Color color1 = Color.FromArgb(unchecked((int)0xFF00024d));
Color color2 = Color.FromArgb(unchecked((int)0xFFd6a20f));
Brush b = new LinearGradientBrush(r, color1, color2, LinearGradientMode.Horizontal);
e.Graphics.FillRectangle(b, r);
}
我得到了一个正确绘制的矩形:
但如果我将矩形宽度更改为203像素:
Rectangle r = new Rectangle(50, 50, 203, 50);
矩形左侧有彩色边缘或环绕:
![enter image description here](https://istack.dev59.com/iO050.webp)
202px:
![enter image description here](https://istack.dev59.com/DkYA0.webp)
![enter image description here](https://istack.dev59.com/dNhhM.webp)