Skip to content

FillRule

Summary

Specifies how the intersecting areas of PathFigure objects contained in a Geometry are combined to form the area of the Geometry.

Signature

1
public enum FillRule

Namespace

cAlgo.API

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
 using cAlgo.API;
 namespace cAlgo
 {
     // This sample shows the use of FillRule
     [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
     public class FillRuleSample : Indicator
     {
         protected override void Initialize()
         {
             var stackPanelNonzero = new StackPanel()
             {
                 HorizontalAlignment = HorizontalAlignment.Center,
                 VerticalAlignment = VerticalAlignment.Center,
                 BackgroundColor = Color.Gold,
                 Opacity = 0.6,
             };
             stackPanelNonzero.AddChild(new TextBlock { Text = "Nonzero", ForegroundColor = Color.Black, HorizontalAlignment = HorizontalAlignment.Center, Margin = 10 });
             stackPanelNonzero.AddChild(new Polygon
             {
                 FillColor = Color.Red,
                 Width = 200,
                 Height = 100,
                 FillRule = FillRule.Nonzero,
                 Margin = 10,
                 Points = new Point[]
                 {
                     new Point(1, 200),
                     new Point(50, 30),
                     new Point(100, 1),
                     new Point(150, 1),
                     new Point(100, 10),
                     new Point(50, 1),
                     new Point(200, 70),
                     new Point(300, 90),
                 }
             });
             stackPanelNonzero.AddChild(new TextBlock { Text = "EvenOdd", ForegroundColor = Color.Black, HorizontalAlignment = HorizontalAlignment.Center, Margin = 10 });
             stackPanelNonzero.AddChild(new Polygon
             {
                 FillColor = Color.Red,
                 Width = 200,
                 Height = 100,
                 FillRule = FillRule.EvenOdd,
                 Margin = 10,
                 Points = new Point[]
                 {
                     new Point(1, 200),
                     new Point(50, 30),
                     new Point(100, 1),
                     new Point(150, 1),
                     new Point(100, 10),
                     new Point(50, 1),
                     new Point(200, 70),
                     new Point(300, 90),
                 }
             });
             Chart.AddControl(stackPanelNonzero);
         }
         public override void Calculate(int index)
         {
         }
     }
 }
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 import clr
 clr.AddReference("cAlgo.API")
 from cAlgo.API import *
 class Test():    
     def initialize(self):
         stackPanel = StackPanel()
         stackPanel.HorizontalAlignment = HorizontalAlignment.Center
         stackPanel.VerticalAlignment = VerticalAlignment.Center
         stackPanel.BackgroundColor = Color.Gold
         stackPanel.Opacity = 0.6
         nonZeroTextBlock = TextBlock()
         nonZeroTextBlock.Text = "Nonzero"
         nonZeroTextBlock.ForegroundColor = Color.Black
         nonZeroTextBlock.HorizontalAlignment = HorizontalAlignment.Center
         nonZeroTextBlock.Margin = Thickness(10)
         stackPanel.AddChild(nonZeroTextBlock)
         polygon = Polygon()
         polygon.FillColor = Color.Red
         polygon.Width = 200
         polygon.Height = 100
         polygon.FillRule = FillRule.Nonzero
         polygon.Margin = Thickness(10)
         polygon.Points = [Point(1, 200), Point(50, 30), Point(100, 1), Point(150, 1), Point(100, 10), Point(50, 1), Point(200, 70), Point(300, 90)]
         stackPanel.AddChild(polygon)
         evenOddTextBlock = TextBlock()
         evenOddTextBlock.Text = "EvenOdd"
         evenOddTextBlock.ForegroundColor = Color.Black
         evenOddTextBlock.HorizontalAlignment = HorizontalAlignment.Center
         evenOddTextBlock.Margin = Thickness(10)
         stackPanel.AddChild(evenOddTextBlock)
         polygon = Polygon()
         polygon.FillColor = Color.Red
         polygon.Width = 200
         polygon.Height = 100
         polygon.FillRule = FillRule.EvenOdd
         polygon.Margin = Thickness(10)
         polygon.Points = [Point(1, 200), Point(50, 30), Point(100, 1), Point(150, 1), Point(100, 10), Point(50, 1), Point(200, 70), Point(300, 90)]
         stackPanel.AddChild(polygon)
         api.Chart.AddControl(stackPanel)

Fields

EvenOdd

Summary

Rule that determines whether a point is in the fill region by drawing a ray from that point to infinity in any direction and counting the number of path segments within the given shape that the ray crosses. If this number is odd, the point is inside; if even, the point is outside.

Signature

1
FillRule.EvenOdd;

Return Value

FillRule

Nonzero

Summary

Rule that determines whether a point is in the fill region of the path by drawing a ray from that point to infinity in any direction and then examining the places where a segment of the shape crosses the ray. Starting with a count of zero, add one each time a segment crosses the ray from left to right and subtract one each time a path segment crosses the ray from right to left. After counting the crossings, if the result is zero then the point is outside the path. Otherwise, it is inside.

Signature

1
FillRule.Nonzero;

Return Value

FillRule