# Xui.Runtime.Software.Tessellate

Assembly: **Xui.Runtime.Software** · [C# declarations](index.cs) · [Assembly overview](../index.md)

## Types

- [`class PathTesselator`](#api-a89a14190494b0f1)
- [`readonly struct PathTesselator.ClosedContour`](#api-f04dccc3b321c709)
- [`enum PathTesselator.ClosedContour.WindingDirection`](#api-843b2b2c598eafe8)
- [`class PathTesselator.Contouring`](#api-71a6c8566f2a3df7)
- [`class PathTesselator.ScanlineSweep`](#api-1594ec4a0bdfe346)
- [`readonly struct PathTesselator.ScanlineSweep.Edge`](#api-46acc6404e179c47)
- [`readonly struct Polygon`](#api-3f10dbba77ae0ecf)
- [`readonly struct Trapezoid`](#api-337339be43f9854d)

<a id="api-a89a14190494b0f1"></a>

## `class PathTesselator`

Represents a full tessellation pipeline result, including intermediate geometric representations. Used for visual debugging, documentation, and rendering filled polygons from vector paths.

```csharp
public partial class PathTesselator
{
    public readonly struct ClosedContour
    {
        public readonly IReadOnlyList<Point> Points;
        public ClosedContour(IReadOnlyList<Point> points);
        public int Count { get; }

        public Point this[int index] { get; }

        public enum WindingDirection
        {
            Clockwise,
            CounterClockwise
        }

        public WindingDirection Winding { get; }
        public Rect Bounds { get; }
        public nfloat SignedArea { get; }
    }
}
public partial class PathTesselator
{
    public class Contouring : IPathBuilder
    {
        public IReadOnlyList<ClosedContour> Contours { get; }

        public Contouring();
        public Contouring(nfloat precision);
        public List<ClosedContour> Result { get; }

        public static IReadOnlyList<ClosedContour> ContourPath(Path2D path, nfloat precision);
        public void BeginPath();
        public void MoveTo(Point to);
        public void LineTo(Point to);
        public void CurveTo(Point cp1, Point cp2, Point to);
        public void CurveTo(Point control, Point to);
        public void Arc(Point center, nfloat radius, nfloat startAngle, nfloat endAngle, Winding winding = Winding.ClockWise);
        public void Ellipse(Point center, nfloat rx, nfloat ry, nfloat rotation, nfloat startAngle, nfloat endAngle, Winding winding = Winding.ClockWise);
        public void ArcTo(Point cp1, Point cp2, nfloat radius);
        public void Rect(Rect rect);
        public void RoundRect(Rect rect, nfloat radius);
        public void RoundRect(Rect rect, CornerRadius radius);
        public void ClosePath();
    }
}
public partial class PathTesselator
{
    public partial class ScanlineSweep
    {
        public static List<Polygon> Fill(IReadOnlyList<ClosedContour> contours, FillRule fillRule);
        public static void SweepAndEmitTrapezoids(IReadOnlyList<ClosedContour> contours, FillRule fillRule, List<Polygon> outputTriangles);
        public static List<PathTesselator.ClosedContour> ExtractLoops(List<PathTesselator.ScanlineSweep.Edge> edges);
        public readonly struct Edge
        {
            public readonly Point Start;
            public readonly Point End;
            public readonly nfloat XAtYMin;
            public readonly nfloat SlopeInv;
            public readonly nfloat YMin;
            public readonly nfloat YMax;
            public readonly int Winding;
            public Edge(Point a, Point b);
            public nfloat XAt(nfloat y);
        }
    }
}
public partial class PathTesselator
{
    public PathTesselator(IReadOnlyList<ClosedContour> contours, List<Polygon> polygons);
    public IReadOnlyList<ClosedContour> Contours { get; }
    public List<Polygon> Polygons { get; }

    public static PathTesselator Fill(Path2D path, FillRule fillRule, nfloat flatness);
    public static PathTesselator Fill(Path2D path, FillRule fillRule);
}
```

<a id="api-254aa061b9f8644b"></a>

### [`PathTesselator.PathTesselator(IReadOnlyList<ClosedContour> contours, List<Polygon> polygons)`](#api-254aa061b9f8644b)


```csharp
public PathTesselator(IReadOnlyList<ClosedContour> contours, List<Polygon> polygons);
```



<a id="api-151e62e91084a6cf"></a>

### [`IReadOnlyList<ClosedContour> PathTesselator.Contours`](#api-151e62e91084a6cf)


```csharp
public IReadOnlyList<ClosedContour> Contours { get; }
```

Gets the list of closed contours reconstructed from the segments. Each contour represents a loop used in fill evaluation.

<a id="api-44625ab1e0f797b5"></a>

### [`PathTesselator PathTesselator.Fill(Path2D path, FillRule fillRule)`](#api-44625ab1e0f797b5)


```csharp
public static PathTesselator Fill(Path2D path, FillRule fillRule);
```



<a id="api-4239a8e2a2c3d0d4"></a>

### [`PathTesselator PathTesselator.Fill(Path2D path, FillRule fillRule, NFloat flatness)`](#api-4239a8e2a2c3d0d4)


```csharp
public static PathTesselator Fill(Path2D path, FillRule fillRule, nfloat flatness);
```

Performs full tessellation of a vector path into filled triangle polygons using a specified fill rule. Intermediate data including segments, contours, and trapezoids is retained for debugging or visualization.

- **`path`** — The vector path to tessellate.

- **`fillRule`** — The fill rule (EvenOdd or NonZero) to apply during sweep.

- **`flatness`** — The curve flattening tolerance. Smaller values yield more segments.

**Returns:** A [`Xui.Runtime.Software.Tessellate.PathTesselator`](../xui-runtime-software-tessellate/index.md#api-a89a14190494b0f1) instance containing all stages of the tessellation pipeline.

<a id="api-7aa75921766a2296"></a>

### [`List<Polygon> PathTesselator.Polygons`](#api-7aa75921766a2296)


```csharp
public List<Polygon> Polygons { get; }
```

Gets the final list of filled triangle polygons that represent the tessellated shape.


<a id="api-f04dccc3b321c709"></a>

## `readonly struct PathTesselator.ClosedContour`

Represents a closed contour — a sequence of connected points forming a polygon loop.

```csharp
public readonly struct ClosedContour
{
    public readonly IReadOnlyList<Point> Points;
    public ClosedContour(IReadOnlyList<Point> points);
    public int Count { get; }

    public Point this[int index] { get; }

    public enum WindingDirection
    {
        Clockwise,
        CounterClockwise
    }

    public WindingDirection Winding { get; }
    public Rect Bounds { get; }
    public nfloat SignedArea { get; }
}
```

<a id="api-759750b4659f6cf8"></a>

### [`ClosedContour.ClosedContour(IReadOnlyList<Point> points)`](#api-759750b4659f6cf8)


```csharp
public ClosedContour(IReadOnlyList<Point> points);
```

Initializes a new closed contour from a sequence of points.

<a id="api-a32fab2f56c9d7ef"></a>

### [`Rect ClosedContour.Bounds`](#api-a32fab2f56c9d7ef)


```csharp
public Rect Bounds { get; }
```



<a id="api-a8fbce2326fb091e"></a>

### [`int ClosedContour.Count`](#api-a8fbce2326fb091e)


```csharp
public int Count { get; }
```

Returns the number of points in this contour.

<a id="api-68fa2bb27dfac12f"></a>

### [`Point ClosedContour.this[int index]`](#api-68fa2bb27dfac12f)


```csharp
public Point this[int index] { get; }
```

Indexer access to individual points.

<a id="api-4538846b7505e32e"></a>

### [`IReadOnlyList<Point> ClosedContour.Points`](#api-4538846b7505e32e)


```csharp
public readonly IReadOnlyList<Point> Points;
```

Ordered list of points forming the closed contour path.

<a id="api-4040d26616603bd5"></a>

### [`NFloat ClosedContour.SignedArea`](#api-4040d26616603bd5)


```csharp
public nfloat SignedArea { get; }
```



<a id="api-ac0142acd9fdcf77"></a>

### [`WindingDirection ClosedContour.Winding`](#api-ac0142acd9fdcf77)


```csharp
public WindingDirection Winding { get; }
```




<a id="api-843b2b2c598eafe8"></a>

## `enum PathTesselator.ClosedContour.WindingDirection`



```csharp
public enum WindingDirection
{
    Clockwise,
    CounterClockwise
}
```

<a id="api-65072b32dd70b27a"></a>

### [`WindingDirection.Clockwise`](#api-65072b32dd70b27a)


```csharp
Clockwise
```



<a id="api-c6bc44b439f156bd"></a>

### [`WindingDirection.CounterClockwise`](#api-c6bc44b439f156bd)


```csharp
CounterClockwise
```




<a id="api-71a6c8566f2a3df7"></a>

## `class PathTesselator.Contouring`



```csharp
public class Contouring : IPathBuilder
{
    public IReadOnlyList<ClosedContour> Contours { get; }

    public Contouring();
    public Contouring(nfloat precision);
    public List<ClosedContour> Result { get; }

    public static IReadOnlyList<ClosedContour> ContourPath(Path2D path, nfloat precision);
    public void BeginPath();
    public void MoveTo(Point to);
    public void LineTo(Point to);
    public void CurveTo(Point cp1, Point cp2, Point to);
    public void CurveTo(Point control, Point to);
    public void Arc(Point center, nfloat radius, nfloat startAngle, nfloat endAngle, Winding winding = Winding.ClockWise);
    public void Ellipse(Point center, nfloat rx, nfloat ry, nfloat rotation, nfloat startAngle, nfloat endAngle, Winding winding = Winding.ClockWise);
    public void ArcTo(Point cp1, Point cp2, nfloat radius);
    public void Rect(Rect rect);
    public void RoundRect(Rect rect, nfloat radius);
    public void RoundRect(Rect rect, CornerRadius radius);
    public void ClosePath();
}
```

<a id="api-4e32612c98f22224"></a>

### [`Contouring.Contouring()`](#api-4e32612c98f22224)


```csharp
public Contouring();
```



<a id="api-cab43eaeb05a2ec1"></a>

### [`Contouring.Contouring(NFloat precision)`](#api-cab43eaeb05a2ec1)


```csharp
public Contouring(nfloat precision);
```



<a id="api-a5b5c1eb0cbb2132"></a>

### [`void Contouring.Arc(Point center, NFloat radius, NFloat startAngle, NFloat endAngle, Winding winding = Winding.ClockWise)`](#api-a5b5c1eb0cbb2132)


```csharp
public void Arc(Point center, nfloat radius, nfloat startAngle, nfloat endAngle, Winding winding = Winding.ClockWise);
```



<a id="api-39b03b72f2e807e2"></a>

### [`void Contouring.ArcTo(Point cp1, Point cp2, NFloat radius)`](#api-39b03b72f2e807e2)


```csharp
public void ArcTo(Point cp1, Point cp2, nfloat radius);
```



<a id="api-cf37c806c3443ff9"></a>

### [`void Contouring.BeginPath()`](#api-cf37c806c3443ff9)


```csharp
public void BeginPath();
```



<a id="api-4c5204963343b69c"></a>

### [`void Contouring.ClosePath()`](#api-4c5204963343b69c)


```csharp
public void ClosePath();
```



<a id="api-65ef53e3764cce19"></a>

### [`IReadOnlyList<ClosedContour> Contouring.ContourPath(Path2D path, NFloat precision)`](#api-65ef53e3764cce19)


```csharp
public static IReadOnlyList<ClosedContour> ContourPath(Path2D path, nfloat precision);
```



<a id="api-6da75a3c589f5a50"></a>

### [`IReadOnlyList<ClosedContour> Contouring.Contours`](#api-6da75a3c589f5a50)


```csharp
public IReadOnlyList<ClosedContour> Contours { get; }
```



<a id="api-4558b6eab7fa13e7"></a>

### [`void Contouring.CurveTo(Point control, Point to)`](#api-4558b6eab7fa13e7)


```csharp
public void CurveTo(Point control, Point to);
```



<a id="api-3c275855cce26ceb"></a>

### [`void Contouring.CurveTo(Point cp1, Point cp2, Point to)`](#api-3c275855cce26ceb)


```csharp
public void CurveTo(Point cp1, Point cp2, Point to);
```



<a id="api-ee17f89416ddef32"></a>

### [`void Contouring.Ellipse(Point center, NFloat rx, NFloat ry, NFloat rotation, NFloat startAngle, NFloat endAngle, Winding winding = Winding.ClockWise)`](#api-ee17f89416ddef32)


```csharp
public void Ellipse(Point center, nfloat rx, nfloat ry, nfloat rotation, nfloat startAngle, nfloat endAngle, Winding winding = Winding.ClockWise);
```



<a id="api-ebb01c369335b8f0"></a>

### [`void Contouring.LineTo(Point to)`](#api-ebb01c369335b8f0)


```csharp
public void LineTo(Point to);
```



<a id="api-801f0052d5e22014"></a>

### [`void Contouring.MoveTo(Point to)`](#api-801f0052d5e22014)


```csharp
public void MoveTo(Point to);
```



<a id="api-5af2018eb6f6f3c3"></a>

### [`void Contouring.Rect(Rect rect)`](#api-5af2018eb6f6f3c3)


```csharp
public void Rect(Rect rect);
```



<a id="api-dcaec7a9106fd018"></a>

### [`List<ClosedContour> Contouring.Result`](#api-dcaec7a9106fd018)


```csharp
public List<ClosedContour> Result { get; }
```



<a id="api-8112852cc2eb83d3"></a>

### [`void Contouring.RoundRect(Rect rect, NFloat radius)`](#api-8112852cc2eb83d3)


```csharp
public void RoundRect(Rect rect, nfloat radius);
```



<a id="api-4ab3ebd0378917ca"></a>

### [`void Contouring.RoundRect(Rect rect, CornerRadius radius)`](#api-4ab3ebd0378917ca)


```csharp
public void RoundRect(Rect rect, CornerRadius radius);
```




<a id="api-1594ec4a0bdfe346"></a>

## `class PathTesselator.ScanlineSweep`



```csharp
public partial class ScanlineSweep
{
    public static List<Polygon> Fill(IReadOnlyList<ClosedContour> contours, FillRule fillRule);
    public static void SweepAndEmitTrapezoids(IReadOnlyList<ClosedContour> contours, FillRule fillRule, List<Polygon> outputTriangles);
    public static List<PathTesselator.ClosedContour> ExtractLoops(List<PathTesselator.ScanlineSweep.Edge> edges);
    public readonly struct Edge
    {
        public readonly Point Start;
        public readonly Point End;
        public readonly nfloat XAtYMin;
        public readonly nfloat SlopeInv;
        public readonly nfloat YMin;
        public readonly nfloat YMax;
        public readonly int Winding;
        public Edge(Point a, Point b);
        public nfloat XAt(nfloat y);
    }
}
```

<a id="api-63109526bcc15189"></a>

### [`List<ClosedContour> ScanlineSweep.ExtractLoops(List<Edge> edges)`](#api-63109526bcc15189)


```csharp
public static List<PathTesselator.ClosedContour> ExtractLoops(List<PathTesselator.ScanlineSweep.Edge> edges);
```

Extracts all closed, non-intersecting loops from a set of directed edges. Each loop is returned as a ClosedContour.

<a id="api-3f7f909603356197"></a>

### [`List<Polygon> ScanlineSweep.Fill(IReadOnlyList<ClosedContour> contours, FillRule fillRule)`](#api-3f7f909603356197)


```csharp
public static List<Polygon> Fill(IReadOnlyList<ClosedContour> contours, FillRule fillRule);
```



<a id="api-fddc29745cb5cc54"></a>

### [`void ScanlineSweep.SweepAndEmitTrapezoids(IReadOnlyList<ClosedContour> contours, FillRule fillRule, List<Polygon> outputTriangles)`](#api-fddc29745cb5cc54)


```csharp
public static void SweepAndEmitTrapezoids(IReadOnlyList<ClosedContour> contours, FillRule fillRule, List<Polygon> outputTriangles);
```




<a id="api-46acc6404e179c47"></a>

## `readonly struct PathTesselator.ScanlineSweep.Edge`



```csharp
public readonly struct Edge
{
    public readonly Point Start;
    public readonly Point End;
    public readonly nfloat XAtYMin;
    public readonly nfloat SlopeInv;
    public readonly nfloat YMin;
    public readonly nfloat YMax;
    public readonly int Winding;
    public Edge(Point a, Point b);
    public nfloat XAt(nfloat y);
}
```

<a id="api-2eb4c2606d8309c9"></a>

### [`Edge.Edge(Point a, Point b)`](#api-2eb4c2606d8309c9)


```csharp
public Edge(Point a, Point b);
```



<a id="api-54f068a0b000933b"></a>

### [`Point Edge.End`](#api-54f068a0b000933b)


```csharp
public readonly Point End;
```



<a id="api-ee03066e90a24fc1"></a>

### [`NFloat Edge.SlopeInv`](#api-ee03066e90a24fc1)


```csharp
public readonly nfloat SlopeInv;
```



<a id="api-63caeaa1e2acd7b2"></a>

### [`Point Edge.Start`](#api-63caeaa1e2acd7b2)


```csharp
public readonly Point Start;
```



<a id="api-767f06e1f29c7e77"></a>

### [`int Edge.Winding`](#api-767f06e1f29c7e77)


```csharp
public readonly int Winding;
```



<a id="api-9c20cbc2ed74081f"></a>

### [`NFloat Edge.XAt(NFloat y)`](#api-9c20cbc2ed74081f)


```csharp
public nfloat XAt(nfloat y);
```



<a id="api-d89bac702e35ea47"></a>

### [`NFloat Edge.XAtYMin`](#api-d89bac702e35ea47)


```csharp
public readonly nfloat XAtYMin;
```



<a id="api-3d35ee6515a154b3"></a>

### [`NFloat Edge.YMax`](#api-3d35ee6515a154b3)


```csharp
public readonly nfloat YMax;
```



<a id="api-e92c0f308e255722"></a>

### [`NFloat Edge.YMin`](#api-e92c0f308e255722)


```csharp
public readonly nfloat YMin;
```




<a id="api-3f10dbba77ae0ecf"></a>

## `readonly struct Polygon`

Represents a triangle polygon used during path tessellation.

```csharp
public readonly struct Polygon : IEnumerable<Point>
{
    public readonly Point A;
    public readonly Point B;
    public readonly Point C;
    public Polygon(Point a, Point b, Point c);
    public IEnumerator<Point> GetEnumerator();
}
```

<a id="api-bf71094856eb3264"></a>

### [`Polygon.Polygon(Point a, Point b, Point c)`](#api-bf71094856eb3264)


```csharp
public Polygon(Point a, Point b, Point c);
```



<a id="api-4c3a5d1be1694282"></a>

### [`Point Polygon.A`](#api-4c3a5d1be1694282)


```csharp
public readonly Point A;
```



<a id="api-383a40124412e17f"></a>

### [`Point Polygon.B`](#api-383a40124412e17f)


```csharp
public readonly Point B;
```



<a id="api-2dedda8a4a62c085"></a>

### [`Point Polygon.C`](#api-2dedda8a4a62c085)


```csharp
public readonly Point C;
```



<a id="api-aeaec2edf5cb58e1"></a>

### [`IEnumerator<Point> Polygon.GetEnumerator()`](#api-aeaec2edf5cb58e1)


```csharp
public IEnumerator<Point> GetEnumerator();
```




<a id="api-337339be43f9854d"></a>

## `readonly struct Trapezoid`



```csharp
public readonly struct Trapezoid : IEnumerable<Polygon>
{
    public readonly Point A;
    public readonly Point B;
    public readonly Point C;
    public readonly Point D;
    public Trapezoid(Point a, Point b, Point c, Point d);
    public Polygon Polygon1 { get; }
    public Polygon Polygon2 { get; }

    public IEnumerator<Polygon> GetEnumerator();
}
```

<a id="api-6171b49a61f2b500"></a>

### [`Trapezoid.Trapezoid(Point a, Point b, Point c, Point d)`](#api-6171b49a61f2b500)


```csharp
public Trapezoid(Point a, Point b, Point c, Point d);
```



<a id="api-3d399f456f3cc7ce"></a>

### [`Point Trapezoid.A`](#api-3d399f456f3cc7ce)


```csharp
public readonly Point A;
```



<a id="api-d9bce2c5aa7c9e33"></a>

### [`Point Trapezoid.B`](#api-d9bce2c5aa7c9e33)


```csharp
public readonly Point B;
```



<a id="api-901b848aa3f85034"></a>

### [`Point Trapezoid.C`](#api-901b848aa3f85034)


```csharp
public readonly Point C;
```



<a id="api-477a647b2ecd27bc"></a>

### [`Point Trapezoid.D`](#api-477a647b2ecd27bc)


```csharp
public readonly Point D;
```



<a id="api-f0d2324350c051a2"></a>

### [`IEnumerator<Polygon> Trapezoid.GetEnumerator()`](#api-f0d2324350c051a2)


```csharp
public IEnumerator<Polygon> GetEnumerator();
```



<a id="api-f1cf7fb9ba2d23f9"></a>

### [`Polygon Trapezoid.Polygon1`](#api-f1cf7fb9ba2d23f9)


```csharp
public Polygon Polygon1 { get; }
```



<a id="api-007468c7a7f203c5"></a>

### [`Polygon Trapezoid.Polygon2`](#api-007468c7a7f203c5)


```csharp
public Polygon Polygon2 { get; }
```



