---
id: "T:cAlgo.API.FillRule"
kind: "enum"
namespace: "cAlgo.API"
url: "https://help.ctrader.com/ctrader-algo/references/Controls/Layout/Shapes/FillRule/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# FillRule (enum)

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

Environments: Desktop supported · CLI supported · Cloud supported.

## Definition

```csharp
public enum FillRule
```

## Examples

C#:

```csharp
using cAlgo.API;

namespace cAlgo
{
    // This sample shows the use of FillRule
    public partial 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)
        {
        }
    }
}
```

Python:

```python
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)
```

config.json:

```json
{
  "AccessRights": "None",
  "TimeZone": "UTC",
  "IsOverlay": true
}
```

## Values

- `FillRule.EvenOdd` — 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.
- `FillRule.Nonzero` — 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.

