正文

GDI+: Introduction to Brushes2006-06-19 20:00:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/iamben250/16020.html

分享到:

Introduction

Line-based and closed shapes figure require a pen to show their shape. The particularity with closed shapes is that they can be filled, with a color, a picture, or a pattern.

A brush is an object that holds a color, a picture, or a drawing pattern and that is used to fill the interior of a closed shape. This definition also means that there are various types of brushes with different goals. To meet these goals, the .NET Framework provides support for brushes in various namespaces with different classes. The parent of all brushes is the Brush class defined in the System.Drawing namespace.

Using a Brush

Because the main job of a brush is to fill a closed shape, the Graphics class provides a method that corresponds to each of the closed shapes we reviewed to draw in the previous lesson in order to fill it. The methods are:

  • FillRectangle: Used to fill the interior of a rectangle or a square
  • FillRectangle: Used to fill the interior of a series of rectangles
  • FillEllipse: Used to fill the interior of an ellipse or a circle
  • FillPolygon: Used to fill the interior of a polygon
  • FillPie: Used to fill the interior of a pie
  • FillPath: Used to fill the interior of a graphic path

To fill out a shape, call one of these methods, pass it a brush value, followed by the location and dimensions of the shape. For example, if you want to draw a rectangle and fill it with a brush, you would use code similar to:

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) _
			Handles MyBase.Paint
        e.Graphics.FillRectangle(SomeBrush, 20, 20, 200, 160)
End Sub

Over all, there are four types of brushes.

阅读(2466) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册