[WPF] 彩虹画刷小范例
2010-09-07 15:43
483 查看
简单的彩虹笔刷范例,用WPF还真好玩
LinearGradientBrush就可以做线性的渐层
RadialGradientBrush可以做椭圆的渐层
只要将画刷设定到Background属性,就可以在Window填满下列效果了
LinearGradientBrush就可以做线性的渐层
RadialGradientBrush可以做椭圆的渐层
只要将画刷设定到Background属性,就可以在Window填满下列效果了
using System; using System.Windows; using System.Windows.Input; using System.Windows.Media; using System.Reflection; namespace Cloud.GradiateTheBrush { public class GradiateTheBrush : Window { [STAThread] public static void Main() { Application app = new Application(); app.Run(new GradiateTheBrush()); } public GradiateTheBrush() { this.Title = "Gradiate Brush"; //LinearGradientBrush brush = new LinearGradientBrush(); //brush.StartPoint = new Point(0, 0); //brush.EndPoint = new Point(1, 0); RadialGradientBrush brush = new RadialGradientBrush(); this.Background = brush; brush.GradientStops.Add(new GradientStop(Colors.Red, 0)); brush.GradientStops.Add(new GradientStop(Colors.Orange, 0.17)); brush.GradientStops.Add(new GradientStop(Colors.Yellow, 0.33)); brush.GradientStops.Add(new GradientStop(Colors.Green, 0.5)); brush.GradientStops.Add(new GradientStop(Colors.Blue, 0.67)); brush.GradientStops.Add(new GradientStop(Colors.Indigo, 0.84)); brush.GradientStops.Add(new GradientStop(Colors.Violet, 1)); } } }
相关文章推荐
- [WPF] TextBlock小范例
- 使用微软Kinect进行手势识别操作的一个简单范例(WPF-C#)
- 创建ADO.NET Entity Framework 和 WPF 范例程序(提供范例程序下载)
- 使用微软Kinect进行手势识别操作的一个简单范例(2)(WPF-C#)
- WPF TreeView 绑定到层次结构数据库
- 互斥锁使用范例
- WPF 双击事件
- WPF-DataGrid中CheckBox实现全选与非全选
- wpf学习 提示信息
- Understanding WPF Template
- VC++网络安全编程范例(4)-创建自签名证书打包与拆解
- WPF: Changing sizes of grid rows and columns during runtime
- shell编程范例
- WPF绘制深度不同颜色的3D模型填充图和线框图
- WPF in Action with Visual Studio 2008
- wpf 曙光初现
- WPF程序员自定义控库系列(一)——图片按钮
- WPF应用程序如何重启当前的Application
- c# wpf启动外部exe并嵌入到启动主窗口中运行
- WPF开发的ARPG游戏引擎(WPF Game Engine)