扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:王凯明 来源:论坛 2007年11月14日
关键字:
using System; using System.Windows.Forms; using System.Drawing; using System.Drawing.Drawing2D; public class LinearGradientbru:Form { public LinearGradientbru() { this.Text = "运用LinearGradientBrush示例"; this.Paint += new PaintEventHandler(Fill_Graph); } public void Fill_Graph(object sender,PaintEventArgs e) { Rectangle r = new Rectangle(500, 300, 100, 100); LinearGradientBrush lb = new LinearGradientBrush(r, Color.Red, Color.Yellow, LinearGradientMode.BackwardDiagonal); e.Graphics.FillRectangle(lb, r); } public static void Main() { Application.Run(new LinearGradientbru()); } } |
using System; using System.Windows.Forms; using System.Drawing; using System.Drawing.Drawing2D; public class PathGradientbru:Form { public PathGradientbru() { this.Text = "运用PathGradientBrush示例"; this.Paint += new PaintEventHandler(Fill_Graph); } public void Fill_Graph(object sender,PaintEventArgs e) { e.Graphics.TextRenderingHint = TextRenderingHint.AntiAliased; e.Graphics.FillRectangle(backgroundBrush, ClientRectangle); e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(180, Color.White)), ClientRectangle); //先设置好一个路径 GraphicsPath path = new GraphicsPath(new Point[] { new Point(40, 140), new Point(275, 200), new Point(105, 225), new Point(190, 300), new Point(50, 350), new Point(20, 180), }, new byte[] { (byte)PathPointType.Start, (byte)PathPointType.Bezier, (byte)PathPointType.Bezier, (byte)PathPointType.Bezier, (byte)PathPointType.Line, (byte)PathPointType.Line, }); //创建一把PathGradientBrush PathGradientBrush pgb = new PathGradientBrush(path); //设置画刷的周围颜色 pgb.SurroundColors = new Color[] { Color.Green, Color.Yellow, Color.Red, Color.Blue, Color.Orange, Color.White, }; //用画刷进行填充 e.Graphics.FillPath(pgb, path); } public static void Main() { Application.Run(new PathGradientbru()); } } |
using System; using System.Windows.Forms; using System.Drawing; using System.Drawing.Drawing2D; public class Texturedbru:Form { Brush bgbrush; public Texturedbru() { //创建一幅图像以供填充椭圆的背景用 Image bgimage = new Bitmap("dotnet.gif"); bgbrush = new TextureBrush(bgimage); this.Paint+=new PaintEventHandler(Text_bru); } public void Text_bru(object sender,PaintEventArgs e) { Graphics g = e.Graphics; g.FillEllipse(bgbrush,50,50,500,300); } public static void Main() { Application.Run(new Texturedbru()); } } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者