首页 > 代码库 > 线性梯度画刷

线性梯度画刷

using (Graphics graphics = this.CreateGraphics())            {// graphics.Clear(Color.White);                 Pen pen = new Pen(Color.Red, 2);                //SolidBrush brush = new SolidBrush(Color.Black);                  //定义一个渐变线偏转角度为30度的渐变画刷,大小40*20                LinearGradientBrush lgb = new LinearGradientBrush(                    new Rectangle(0, 0, 40, 20),                    Color.Green,                    Color.Blue, 45.0f);                //使用偏转角度为30度的渐变画刷填充区域                graphics.FillRectangle(lgb, new Rectangle(150, 20, 120, 120));                graphics.DrawRectangle(pen, new Rectangle(150, 20, 120, 120));            }

技术分享

线性梯度画刷