Monday, April 23, 2007

Colors in GDI+

One of my most favorite for creating component is playing with colors. With colors, we can create fancy controls for our application and present an "eye candy" application for the user. In this articles, you will find a way to playing with color from using simple basic color to creating advanced gradient color.

Part I: The Brush Object

To make a color, we need a Brush object from Graphics. There are 4 type of brush:

  1. Solid Brush : A plain color
  2. Hatch Brush : A color with hatch effect
  3. Texture Brush : A texture filled object
  4. Gradient Brush : A gradient color brush

Part II: Simple brush

To apply a color to your drawing, you need a graphic object to draw. It can be a pen or a shape.

Ex:


GDI+ has so many objects for displaying. They are:

  • Ellipses
  • Rectangles
  • Arcs (Arc is a portion of ellipse)
  • Beziers
  • Curves
  • Region
  • Path
  • Etc.

Conclusion

GDI+ is a good way for creating nice application UI, components or controls. With learning frequently, you can create any component you want. Your only limit is your creativity. In next section, I'll explain more complex way for manipulating colors using gradients.

No comments: