Nevron .NET Vision Documentation
Shadow Style

Almost all visual objects support shadows and the shadow related properties are wrapped in an instance of the NShadowStyle class. Shadows significantly increase the visual appearance and are an indispensable feature in presentation quality images. Shadow drawing however requires from the control to perform a separate render pass for the object using the shadow. Therefore it is not recommended to use shadows in applications requiring high performance. Furthermore some shadow types are more expensive to render than others.

Following is a detail explanation for each of the shadow style properties.

Shadow Type

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.
Shadow Fade Length

The FadeLength property controls the size of the area where the shadow color distribution will operate. The color distribution function will start from the shadow color and gradually change it's alpha value to completely transparent at the shadow edge. Note that the blur types of shadow use convolution which is computationally expensive. That is why it is recommended to keep the FadeLength in the range [1, 10] for better performance. The following code changes the FadeLength:

C#
Copy Code
shadow.FadeLength = new NLength(10, NGraphicsUnit.Point);
Visual Basic
Copy Code
shadow.FadeLength = New NLength(10, NGraphicsUnit.Point)

When the fade area is set to 0 the control will render the object with solid shadow.

Shadow Color

After you choose the shadow type you can also consider modifying the shadow color:

C#
Copy Code
shadow.Color = Color.FromArgb(125, 0, 0, 0);
Visual Basic
Copy Code
shadow.Color = Color.FromArgb(125, 0, 0, 0)

In general shadows look better when the color is not completely opaque.

Shadow Offset

The Offset property of the NShadowStyle object controls the offset of the shadow from the original object in NPointL format.

C#
Copy Code
shadow.Offset = new NPointL(10, 10);
Visual Basic
Copy Code
shadow.Offset = New NPointL(10, 10)

The code above will offset the shadow with ten points on the right and bottom.

See Also

 

 


©2017. Nevron Software LLC.

Send Feedback