C#中渐变色的代码实例
时间:2010-08-24 来源:明月幾時有
Graphics g = e.Graphics;
LinearGradientBrush brush = new LinearGradientBrush(this.ClientRectangle,Color.SkyBlue, Color.White, LinearGradientMode.Horizontal);
g.FillRectangle(brush, this.ClientRectangle);//画一个渐变色的块
brush.Dispose();
brush = new LinearGradientBrush(this.ClientRectangle, Color.DarkBlue, Color.White, LinearGradientMode.Horizontal);
g.DrawLine(new Pen(brush, 1), 0, 0, this.Width, 0);//渐变色线
g.DrawLine(new Pen(brush, 1), 0, this.Height-1, this.Width, this.Height-1);
brush.Dispose();
g.Dispose();
其中主要是引入LinearGradientBrush,在文件头部
using System.Drawing.Drawing2D;
相关阅读 更多 +