--- title: "How to: Draw with Opaque and Semitransparent Brushes" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "semi-transparent shapes [Windows Forms], drawing" - "transparency [Windows Forms], semi-transparent shapes" - "alpha blending [Windows Forms], brush" - "brushes [Windows Forms], using semi-transparent" ms.assetid: a4f6f6b8-3bc8-440a-84af-d62ef0f8ff40 --- # How to: Draw with Opaque and Semitransparent Brushes When you fill a shape, you must pass a object to one of the fill methods of the class. The one parameter of the constructor is a object. To fill an opaque shape, set the alpha component of the color to 255. To fill a semitransparent shape, set the alpha component to any value from 1 through 254. When you fill a semitransparent shape, the color of the shape is blended with the colors of the background. The alpha component specifies how the shape and background colors are mixed; alpha values near 0 place more weight on the background colors, and alpha values near 255 place more weight on the shape color. ## Example The following example draws a bitmap and then fills three ellipses that overlap the bitmap. The first ellipse uses an alpha component of 255, so it is opaque. The second and third ellipses use an alpha component of 128, so they are semitransparent; you can see the background image through the ellipses. The call that sets the property causes the blending for the third ellipse to be done in conjunction with gamma correction. [!code-csharp[System.Drawing.AlphaBlending#31](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Drawing.AlphaBlending/CS/Class1.cs#31)] [!code-vb[System.Drawing.AlphaBlending#31](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Drawing.AlphaBlending/VB/Class1.vb#31)] The following illustration shows the output of the following code: ![Illustration that shows opaque and semitransparent output.](./media/how-to-draw-with-opaque-and-semitransparent-brushes/compositingquality-ellipse-semitransparent.png) ## Compiling the Code The preceding example is designed for use with Windows Forms, and it requires `e`, which is a parameter of . ## See also - [Graphics and Drawing in Windows Forms](graphics-and-drawing-in-windows-forms.md) - [Alpha Blending Lines and Fills](alpha-blending-lines-and-fills.md) - [How to: Give Your Control a Transparent Background](../controls/how-to-give-your-control-a-transparent-background.md) - [How to: Draw Opaque and Semitransparent Lines](how-to-draw-opaque-and-semitransparent-lines.md)