背景:#EDF0F5 #FAFBE6 #FFF2E2 #FDE6E0 #F3FFE1 #DAFAF3 #EAEAEF 默认  
阅读新闻

浅析C#中图形编程

[日期:2003-07-11] 来源:天极网  作者:王凯明 [字体: ]


  使用画刷对象:

  画刷对象是用特定的颜色、模式或是图像来填充一块区域的。总共有四种类型的画刷:SolidBrush(默认的画刷)、HatchBrush、GradientBrush以及TexturedBrush。下面,我们分别给出实例来进行介绍。

  1、运用SolidBrush:

using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;

public class Solidbru:Form {
public Solidbru() {
this.Text = "运用SolidBrush示例";
this.Paint += new PaintEventHandler(Fill_Graph);
}


public void Fill_Graph(object sender,PaintEventArgs e) {
Graphics g = e.Graphics;
//创建一把SolidBrush并用它来填充一个矩形区域
SolidBrush sb = new SolidBrush(Color.Pink);
g.FillRectangle(sb,50,50,150,150);

}


public static void Main() {
Application.Run(new Solidbru());
}

}



  2、运用HatchBrush:

using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
public class Hatchbru:Form {
public Hatchbru() {
this.Text = "运用HatchBrush示例";
this.Paint += new PaintEventHandler(Fill_Graph);
}

public void Fill_Graph(object sender,PaintEventArgs e) {
Graphics g = e.Graphics;
//创建一把HatchBrush并用它来填充一个矩形区域
/*该画刷的HatchStyle有DiagonalCross、
ForwardDiagonal、Horizontal、 Vertical、 Solid等不同风格 */
HatchStyle hs = HatchStyle.Cross;
HatchBrush sb = new HatchBrush(hs,Color.Blue,Color.Red);
g.FillRectangle(sb,50,50,150,150);
}


public static void Main() {
Application.Run(new Hatchbru());
}

}


上一页12345下一页  GO
阅读:
录入:木鸟

推荐 】 【 打印
上一篇:Vml:美洲豹系列教程之三(Line,Polyline(线)对象)
下一篇:在ASP.NET中将数据直接输出成Excel格式
相关新闻      
本文评论       全部评论
发表评论


点评: 字数
姓名:

  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款