Prev | Current Page 667 | Next

Matthew MacDonald

"Pro WPF with VB 2008: Windows Presentation Foundation with .NET 3.5"

By default, Fill Rule is set to EvenOdd. In order to
decide whether to fill a region, WPF counts the number of lines that must be crossed to reach the
outside of the shape. If this number is odd, the region is filled in; if it??™s even, the region isn??™t filled.
In the center area of Figure 13-9, you must cross two lines to get out of the shape, so it??™s not filled.
WPF also supports the Nonzero fill rule, which is a little trickier. Essentially, with Nonzero,
WPF follows the same line-counting process as EvenOdd, but it takes into account the direction
that each line flows. If the number of lines going in one direction (say, left to right) is
equal to the number going in the opposite direction (right to left), the region is not filled. If the
difference between these two counts is not zero, the region is filled. In the shape from the previous
example, the interior region is filled if you set the FillRule to Nonzero. Figure 13-10
shows why. (In this example, the points are numbered in the order they are drawn, and arrows
show the direction in which each line is drawn.)
Figure 13-10. Determining fill areas when FillRule is Nonzero
CHAPTER 13 n SHAPES, TRANSFORMS, AND BRUSHES 384
nNote If there are an odd number of lines, the difference between the two counts can??™t be zero. Thus, the
Nonzero fill rule always fills at least as much as the EvenOdd rule, plus possibly a bit more.


Pages:
655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679