Advanced 2D Graphics

In Chapters 7 and 8 we learned how to use advanced imaging functions of the Image, Bitmap, and other classes defined in the System.Drawing and System.Drawing.Imaging namespaces. In this chapter we will discuss advanced two-dimensional GDI+ programming. The .NET Framework library defines this functionality in a separate namespace: System.Drawing.Drawing2D. Among the advanced 2D techniques we will discuss are blending, matrices, graphics paths, and gradient brushes.

Note

Before using any class discussed in this chapter, an application should reference the System.Drawing.Drawing2D namespace by adding the following line:

using System.Drawing.Drawing2D

Apart from blending, gradient brushes, graphics containers, graphics paths, and matrix-related classes, the System.Drawing.Drawing2D namespace provides many enumerations. Some of the enumerations we have discussed in previous chapters; the rest will be covered in this chapter.

Table 9.1 lists the classes provided by System.Drawing.Drawing2D. Several of these classes were mentioned in previous chapters. We will discuss them here in more detail.

Table 9.1. System.Drawing.Drawing2D classes

Class

Description

AdjustableArrowCap

An adjustable, arrow-shaped line cap.

Blend

A blend pattern used by linear gradient brushes.

ColorBlend

An array of colors and positions in a multicolor gradient.

CustomLineCap

A custom user-defined line cap.

GraphicsContainer

The internal data of a graphics container. The BeginContainer and EndContainer methods are used to save the state of a Graphics object.

GraphicsPath

A graphics path, which contains a series of connected lines and curves.

GraphicsPathIterator

A graphics path can have many subpaths. This class provides a way to iterate through them.

GraphicsState

Graphics object state, which is returned by the BeginContainer method.

HatchBrush

A hatch brush. Discussed in Chapter 4.

LinearGradientBrush

Linear gradient brush. Discussed in Chapter 4.

Matrix

A 3x3 affine matrix that represents a geometric transformation.

PathData

Contains the graphical data of a graphics path.

PathGradientBrush

A brush that fills a graphics path with a gradient.

RegionData

Data of a region.

Категории