The NShadowStyle object Type property controls the type of shadow to apply. The following code changes the shadow type to Gaussian Blur:
C# |
Copy Code
|
---|---|
NShadowStyle shadowStyle = someObjectSupportingShadows.ShadowStyle; shadowStyle.Type = ShadowType.GaussianBlur; |
Visual Basic |
Copy Code
|
---|---|
Dim shadowStyle As NShadowStyle = someObjectSupportingShadows.ShadowStyle shadowStyle.Type = ShadowType.GaussianBlur |
There are four shadow types as shown in the following table:
ShadowType.None | ShadowType.Solid | ShadowType.LinearBlur |
---|---|---|
ShadowType.GaussianBlur | ShadowType.RadialBlur | |
The pictures above show simple text and a rounded rectangle with different shadow styles. Following is a brief description of the shadow types:
- Solid Shadow - the solid shadow is the most common type of shadow used in applications and its greatest advantage is that it is easy and fast to draw. The drawback is that some objects do not look visually appealing when using a solid shadow.
- Linear Blur Shadow - the linear blur shadow uses a linear distribution at the shadow edges. The size of the smooth shadow area is controlled with the help of the FadeLength property of the NShadowStyle object. Note that the linear blur shadow may use a convolution filter if the corresponding shape in GDI+ does not render well by using a PathGradientBrush with properly set focus point. That is why the linear blur is slower than the solid shadow but is recommended over the more expensive types of shadows like Gaussian and Radial, which always use convolution.
- Gaussian Blur Shadow - the Gaussian blur shadow uses a Gaussian distribution (sometimes also called normal distribution) at the shadow edges. The size of the smooth shadow area is controlled with the help of the FadeLength property of the NShadow object. This type of shadow always uses convolution filters and is generally slower than the linear blur and solid types of shadows.
- Radial Blur Shadow - the Radial blur shadow uses a radial distribution at the shadow edges. The size of the smooth shadow area is controlled with the help of the FadeLength property of the NShadowStyle object. This type of shadow always uses convolution filters and is generally slower than the linear blur and solid types of shadows.