08.01.2015 Views

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 16 ■ PROGRAMMING SILVERLIGHT WITH XAML AND JAVASCRIPT 381<br />

The RadialGradientBrush<br />

This is similar to the LinearGradientBrush in that is paints a space using a gradient, but it<br />

does it in a circular manner, with 0 marking the center of the circle <strong>and</strong> 1 being its radius.<br />

Thus, if you have two colors defined, it will look a lot like the effect of a spotlight of the<br />

first color being shown on a wall of the second color, whereby the center of the circle will<br />

be the color of the light, the outer edge of the circle will be the color of the wall, <strong>and</strong> a gradient<br />

between the two will fill the space.<br />

When using the RadialGradientBrush, you don’t need to specify a start point or endpoint,<br />

as the gradient direction will always be from the center of the circle to its outside<br />

edge.<br />

Gradient stops are used in the same manner as the LinearGradientBrush, with the<br />

Offset indicating the unit distance from the center.<br />

Here’s an example of a RadialGradientBrush using the same rainbow colors as the<br />

previous rectangle:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

The RadialGradientBrush gives you some extra control over how the gradient is<br />

painted. The GradientOrigin allows you to set the point at which the gradient emanates. It<br />

doesn’t have to be the center of the circle, so setting it to a different value will “stretch”<br />

the gradient from the center of the circle to the specified point. You set it using a normalized<br />

(x,y) value, where (0.5,0.5) is the center of the circle, (1,1) is the lower right-h<strong>and</strong> side

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!