# Xui.Core.Math2D

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

## Types

- [`struct AffineTransform`](#api-7c6214ea329c24f9)
- [`class Constants`](#api-a04f6e1de92029b4)
- [`struct Frame`](#api-d08fc079b0a96833)
- [`struct Point`](#api-7dfbe8f77fb7adae)
- [`struct Rect`](#api-43aebae21ab1f31f)
- [`struct Size`](#api-348aa93314a72466)
- [`struct Vector`](#api-dc51b72f122240f1)

<a id="api-7c6214ea329c24f9"></a>

## `struct AffineTransform`

Represents a 2D affine transformation matrix in the form: 

```csharp
| A C Tx |
| B D Ty |
| 0 0  1 |
```

 Used for rotating, scaling, translating, and skewing 2D vectors or points.

Transformation is applied as: 

```csharp
| x' |   | A C Tx |   | x |
| y' | = | B D Ty | * | y |
| 1  |   | 0 0  1 |   | 1 |
```

```csharp
public struct AffineTransform
{
    public nfloat A;
    public nfloat B;
    public nfloat C;
    public nfloat D;
    public nfloat Tx;
    public nfloat Ty;
    public static readonly AffineTransform Identity;
    public bool IsIdentity { get; }
    public AffineTransform Inverse {[DebuggerStepThrough]
        get; }
    public nfloat Determinant {[DebuggerStepThrough]
        get; }

    [DebuggerStepThrough]
    public static AffineTransform Rotate(nfloat angle);
    [DebuggerStepThrough]
    public static AffineTransform Translate(Vector v);
    [DebuggerStepThrough]
    public static AffineTransform Scale(Vector v);
    [DebuggerStepThrough]
    public static AffineTransform Shear(nfloat shearX, nfloat shearY);
    [DebuggerStepThrough]
    public AffineTransform(nfloat a, nfloat b, nfloat c, nfloat d, nfloat tx, nfloat ty);
    [DebuggerStepThrough]
    public static Vector operator *(AffineTransform t, Vector v);
    [DebuggerStepThrough]
    public static Point operator *(AffineTransform t, Point p);
    [DebuggerStepThrough]
    public static AffineTransform operator *(AffineTransform lhs, AffineTransform rhs);
    [DebuggerStepThrough]
    public override string ToString();
}
```

<a id="api-b4de5316e7cd4f62"></a>

### [`AffineTransform.AffineTransform(NFloat a, NFloat b, NFloat c, NFloat d, NFloat tx, NFloat ty)`](#api-b4de5316e7cd4f62)


```csharp
[DebuggerStepThrough]
public AffineTransform(nfloat a, nfloat b, nfloat c, nfloat d, nfloat tx, nfloat ty);
```

Constructs an affine transform with the specified matrix coefficients.

<a id="api-7810d3194823cc16"></a>

### [`NFloat AffineTransform.A`](#api-7810d3194823cc16)


```csharp
public nfloat A;
```

The matrix component in the first row, first column (scale X / rotate).

<a id="api-03c42bd7ad1a5dab"></a>

### [`NFloat AffineTransform.B`](#api-03c42bd7ad1a5dab)


```csharp
public nfloat B;
```

The matrix component in the second row, first column (shear Y / rotate).

<a id="api-c6a18fa737b8a207"></a>

### [`NFloat AffineTransform.C`](#api-c6a18fa737b8a207)


```csharp
public nfloat C;
```

The matrix component in the first row, second column (shear X / rotate).

<a id="api-0c624d0a0cc3d7e8"></a>

### [`NFloat AffineTransform.D`](#api-0c624d0a0cc3d7e8)


```csharp
public nfloat D;
```

The matrix component in the second row, second column (scale Y / rotate).

<a id="api-0b95150154fe0dd0"></a>

### [`NFloat AffineTransform.Determinant`](#api-0b95150154fe0dd0)


```csharp
public nfloat Determinant {[DebuggerStepThrough]
    get; }
```

Returns the determinant of the 2&#215;2 linear portion of the matrix.

This value determines if the matrix is invertible. A value of 0 means the matrix cannot be inverted.

<a id="api-a08fb19e75880529"></a>

### [`AffineTransform AffineTransform.Identity`](#api-a08fb19e75880529)


```csharp
public static readonly AffineTransform Identity;
```

The identity transform (no scale, rotation, or translation).

<a id="api-79f63f3c949ac5cb"></a>

### [`AffineTransform AffineTransform.Inverse`](#api-79f63f3c949ac5cb)


```csharp
public AffineTransform Inverse {[DebuggerStepThrough]
    get; }
```

Returns the inverse of this affine transform.

This operation assumes the transform is invertible. Division by a zero determinant will cause a runtime exception.

<a id="api-d792082e54eefb48"></a>

### [`bool AffineTransform.IsIdentity`](#api-d792082e54eefb48)


```csharp
public bool IsIdentity { get; }
```

Returns `true` if the current transform is the identity matrix.

<a id="api-e3c195dfd08abd25"></a>

### [`AffineTransform AffineTransform.Rotate(NFloat angle)`](#api-e3c195dfd08abd25)


```csharp
[DebuggerStepThrough]
public static AffineTransform Rotate(nfloat angle);
```

Creates a rotation transform around the origin using the given angle in radians.

<a id="api-3463a5d76a98a21e"></a>

### [`AffineTransform AffineTransform.Scale(Vector v)`](#api-3463a5d76a98a21e)


```csharp
[DebuggerStepThrough]
public static AffineTransform Scale(Vector v);
```

Creates a scaling transform using the specified scale vector.

<a id="api-6157e585dceb6996"></a>

### [`AffineTransform AffineTransform.Shear(NFloat shearX, NFloat shearY)`](#api-6157e585dceb6996)


```csharp
[DebuggerStepThrough]
public static AffineTransform Shear(nfloat shearX, nfloat shearY);
```

Creates a shear (skew) transformation along the X and Y axes.

- **`shearX`** — The shear factor in the X direction.

- **`shearY`** — The shear factor in the Y direction.

<a id="api-4a32c7d9133b77ce"></a>

### [`string AffineTransform.ToString()`](#api-4a32c7d9133b77ce)


```csharp
[DebuggerStepThrough]
public override string ToString();
```

Returns the fully qualified type name of this instance.

**Returns:** The fully qualified type name.

<a id="api-8d59c8313760c608"></a>

### [`AffineTransform AffineTransform.Translate(Vector v)`](#api-8d59c8313760c608)


```csharp
[DebuggerStepThrough]
public static AffineTransform Translate(Vector v);
```

Creates a translation transform using the specified offset vector.

<a id="api-bef901b5db1d3509"></a>

### [`NFloat AffineTransform.Tx`](#api-bef901b5db1d3509)


```csharp
public nfloat Tx;
```

The translation component along the X axis.

<a id="api-6fd944729a0224f5"></a>

### [`NFloat AffineTransform.Ty`](#api-6fd944729a0224f5)


```csharp
public nfloat Ty;
```

The translation component along the Y axis.

<a id="api-50f3ebe29413b96d"></a>

### [`AffineTransform AffineTransform.operator *(AffineTransform lhs, AffineTransform rhs)`](#api-50f3ebe29413b96d)


```csharp
[DebuggerStepThrough]
public static AffineTransform operator *(AffineTransform lhs, AffineTransform rhs);
```

Composes two affine transforms using matrix multiplication.

**Returns:** A new transform representing the application of `rhs` followed by `lhs`.

<a id="api-afbffd8a5c472bc8"></a>

### [`Point AffineTransform.operator *(AffineTransform t, Point p)`](#api-afbffd8a5c472bc8)


```csharp
[DebuggerStepThrough]
public static Point operator *(AffineTransform t, Point p);
```

Applies this transform to a [`Xui.Core.Math2D.Point`](../xui-core-math2d/index.md#api-7dfbe8f77fb7adae), including translation.

This operation applies the full affine matrix, including scale, rotation, shear, and translation. Use this when transforming coordinates in space (e.g., an element&#39;s position).

- **`t`** — The affine transform.

- **`p`** — The point to transform.

**Returns:** A new [`Xui.Core.Math2D.Point`](../xui-core-math2d/index.md#api-7dfbe8f77fb7adae) with the transform applied.

<a id="api-2f44fb139cd8261c"></a>

### [`Vector AffineTransform.operator *(AffineTransform t, Vector v)`](#api-2f44fb139cd8261c)


```csharp
[DebuggerStepThrough]
public static Vector operator *(AffineTransform t, Vector v);
```

Applies only the linear portion (scale, rotation, shear) of this transform to a [`Xui.Core.Math2D.Vector`](../xui-core-math2d/index.md#api-dc51b72f122240f1).

Translation is not applied. Use this to transform directions, movement deltas, or normals.

- **`t`** — The affine transform.

- **`v`** — The vector to transform.

**Returns:** A new [`Xui.Core.Math2D.Vector`](../xui-core-math2d/index.md#api-dc51b72f122240f1) with the linear transform applied.


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

## `class Constants`

Common mathematical constants used throughout 2D geometry and curve computations.

```csharp
public static class Constants
{
    public static readonly nfloat π;
    public static readonly nfloat τ;
    public static readonly nfloat ε;
    public static readonly nfloat sqrt2;
    public static readonly nfloat ϕ;
}
```

<a id="api-cfe908a07b4e520e"></a>

### [`NFloat Constants.sqrt2`](#api-cfe908a07b4e520e)


```csharp
public static readonly nfloat sqrt2;
```

√2 (square root of 2): Diagonal of a unit square.

<a id="api-0343609308cd7ae5"></a>

### [`NFloat Constants.ε`](#api-0343609308cd7ae5)


```csharp
public static readonly nfloat ε;
```

ε (epsilon): A small value used for numerical stability checks.

<a id="api-1407138cb9f3e48e"></a>

### [`NFloat Constants.π`](#api-1407138cb9f3e48e)


```csharp
public static readonly nfloat π;
```

π (pi): Ratio of a circle’s circumference to its diameter.

<a id="api-de621bfdd94d3b48"></a>

### [`NFloat Constants.τ`](#api-de621bfdd94d3b48)


```csharp
public static readonly nfloat τ;
```

τ (tau): One full circle in radians (2π).

<a id="api-733d02a6329628e8"></a>

### [`NFloat Constants.ϕ`](#api-733d02a6329628e8)


```csharp
public static readonly nfloat ϕ;
```

ϕ (phi): The golden ratio (≈ 1.618).


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

## `struct Frame`

Represents thickness values for each edge of a rectangular element.

A [`Xui.Core.Math2D.Frame`](../xui-core-math2d/index.md#api-d08fc079b0a96833) defines spacing from the left, top, right, and bottom edges. It is typically used for layout constructs such as `Margin`, `Padding`, or `BorderWidth`. Unlike [`Xui.Core.Math2D.Rect`](../xui-core-math2d/index.md#api-43aebae21ab1f31f), it does not represent position or size—only edge offsets.

```csharp
public struct Frame
{
    public nfloat Top;
    public nfloat Right;
    public nfloat Bottom;
    public nfloat Left;
    public bool IsUniform { get; }
    public readonly bool IsZero { get; }
    public nfloat TotalWidth { get; }
    public nfloat TotalHeight { get; }

    public static readonly Frame Zero;
    [DebuggerStepThrough]
    public Frame();
    [DebuggerStepThrough]
    public Frame(nfloat top, nfloat right, nfloat bottom, nfloat left);
    [DebuggerStepThrough]
    public static implicit operator Frame((nfloat top, nfloat right, nfloat bottom, nfloat left) value);
    [DebuggerStepThrough]
    public static implicit operator Frame((nfloat vertical, nfloat horizontal) value);
    [DebuggerStepThrough]
    public static implicit operator Frame(nfloat value);
    [DebuggerStepThrough]
    public static implicit operator Frame(int value);
    [DebuggerStepThrough]
    public static implicit operator Frame(double value);
    [DebuggerStepThrough]
    public static implicit operator Frame(float value);
    [DebuggerStepThrough]
    public static Frame operator *(Frame lhs, nfloat rhs);
    [DebuggerStepThrough]
    public static Frame operator +(Frame lhs, Frame rhs);
    [DebuggerStepThrough]
    public static Frame operator -(Frame lhs, Frame rhs);
    [DebuggerStepThrough]
    public static Frame Max(Frame lhs, Frame rhs);
    [DebuggerStepThrough]
    public static Frame Min(Frame lhs, Frame rhs);
    [DebuggerStepThrough]
    public override string ToString();
    public static bool operator ==(Frame left, Frame right);
    public static bool operator !=(Frame lhs, Frame rhs);
    public override bool Equals(object? obj);
    public override int GetHashCode();
}
```

<a id="api-6a1d2e7c4e21fae9"></a>

### [`Frame.Frame()`](#api-6a1d2e7c4e21fae9)


```csharp
[DebuggerStepThrough]
public Frame();
```

Initializes a new [`Xui.Core.Math2D.Frame`](../xui-core-math2d/index.md#api-d08fc079b0a96833) with all edges set to zero.

<a id="api-321a746d3fb89fcd"></a>

### [`Frame.Frame(NFloat top, NFloat right, NFloat bottom, NFloat left)`](#api-321a746d3fb89fcd)


```csharp
[DebuggerStepThrough]
public Frame(nfloat top, nfloat right, nfloat bottom, nfloat left);
```

Initializes a new [`Xui.Core.Math2D.Frame`](../xui-core-math2d/index.md#api-d08fc079b0a96833) with the specified edge thicknesses.

- **`top`** — Top edge thickness.

- **`right`** — Right edge thickness.

- **`bottom`** — Bottom edge thickness.

- **`left`** — Left edge thickness.

<a id="api-bcf53c17baf50148"></a>

### [`NFloat Frame.Bottom`](#api-bcf53c17baf50148)


```csharp
public nfloat Bottom;
```

The thickness of the bottom edge.

<a id="api-98ac757170f79c28"></a>

### [`bool Frame.Equals(object? obj)`](#api-98ac757170f79c28)


```csharp
public override bool Equals(object? obj);
```

Indicates whether this instance and a specified object are equal.

- **`obj`** — The object to compare with the current instance.

**Returns:** `true` if `obj` and this instance are the same type and represent the same value; otherwise, `false`.

<a id="api-1e6224a7aadc80bd"></a>

### [`int Frame.GetHashCode()`](#api-1e6224a7aadc80bd)


```csharp
public override int GetHashCode();
```

Returns the hash code for this instance.

**Returns:** A 32-bit signed integer that is the hash code for this instance.

<a id="api-1dd7ee911ad955fe"></a>

### [`bool Frame.IsUniform`](#api-1dd7ee911ad955fe)


```csharp
public bool IsUniform { get; }
```

Returns `true` if all four edges have equal thickness.

<a id="api-f4f11b14c501fffb"></a>

### [`readonly bool Frame.IsZero`](#api-f4f11b14c501fffb)


```csharp
public readonly bool IsZero { get; }
```

Returns true if all sides (Left, Top, Right, Bottom) are zero.

<a id="api-9e2e6362fdac61c4"></a>

### [`NFloat Frame.Left`](#api-9e2e6362fdac61c4)


```csharp
public nfloat Left;
```

The thickness of the left edge.

<a id="api-1c9f9f70add8584d"></a>

### [`Frame Frame.Max(Frame lhs, Frame rhs)`](#api-1c9f9f70add8584d)


```csharp
[DebuggerStepThrough]
public static Frame Max(Frame lhs, Frame rhs);
```

Returns a frame containing the maximum value for each edge from two frames.

<a id="api-a833e687a156453b"></a>

### [`Frame Frame.Min(Frame lhs, Frame rhs)`](#api-a833e687a156453b)


```csharp
[DebuggerStepThrough]
public static Frame Min(Frame lhs, Frame rhs);
```

Returns a frame containing the minimum value for each edge from two frames.

<a id="api-0c6b9ce644e15a2a"></a>

### [`NFloat Frame.Right`](#api-0c6b9ce644e15a2a)


```csharp
public nfloat Right;
```

The thickness of the right edge.

<a id="api-2c5ae87873307012"></a>

### [`string Frame.ToString()`](#api-2c5ae87873307012)


```csharp
[DebuggerStepThrough]
public override string ToString();
```

Returns the fully qualified type name of this instance.

**Returns:** The fully qualified type name.

<a id="api-40c2fae70302ce97"></a>

### [`NFloat Frame.Top`](#api-40c2fae70302ce97)


```csharp
public nfloat Top;
```

The thickness of the top edge.

<a id="api-5835be14878a532b"></a>

### [`NFloat Frame.TotalHeight`](#api-5835be14878a532b)


```csharp
public nfloat TotalHeight { get; }
```

Gets the total vertical edge thickness (top + bottom).

<a id="api-dabbf3446807ab07"></a>

### [`NFloat Frame.TotalWidth`](#api-dabbf3446807ab07)


```csharp
public nfloat TotalWidth { get; }
```

Gets the total horizontal edge thickness (left + right).

<a id="api-37d87ab36c7514c0"></a>

### [`Frame Frame.Zero`](#api-37d87ab36c7514c0)


```csharp
public static readonly Frame Zero;
```

A frame with all edge values set to zero.

<a id="api-64c3aeda5e4fb6ac"></a>

### [`Frame Frame.operator +(Frame lhs, Frame rhs)`](#api-64c3aeda5e4fb6ac)


```csharp
[DebuggerStepThrough]
public static Frame operator +(Frame lhs, Frame rhs);
```

Adds the corresponding edge thicknesses of two frames.

<a id="api-8cdedfb30a61dffa"></a>

### [`bool Frame.operator ==(Frame left, Frame right)`](#api-8cdedfb30a61dffa)


```csharp
public static bool operator ==(Frame left, Frame right);
```

Returns `true` if all edge values match exactly.

<a id="api-381faba3249486bf"></a>

### [`Frame.implicit operator Frame(double value)`](#api-381faba3249486bf)


```csharp
[DebuggerStepThrough]
public static implicit operator Frame(double value);
```

Implicitly converts a `System.Double` to a [`Xui.Core.Math2D.Frame`](../xui-core-math2d/index.md#api-d08fc079b0a96833), applying the same value to all four sides (Left, Top, Right, Bottom).

- **`value`** — The double value to apply uniformly to all sides.

**Returns:** A [`Xui.Core.Math2D.Frame`](../xui-core-math2d/index.md#api-d08fc079b0a96833) with all sides set to `value`.

<a id="api-3235e1517a5996d3"></a>

### [`Frame.implicit operator Frame(int value)`](#api-3235e1517a5996d3)


```csharp
[DebuggerStepThrough]
public static implicit operator Frame(int value);
```

Implicitly converts an `System.Int32` to a [`Xui.Core.Math2D.Frame`](../xui-core-math2d/index.md#api-d08fc079b0a96833), applying the same value to all four sides (Left, Top, Right, Bottom).

- **`value`** — The integer value to apply uniformly to all sides.

**Returns:** A [`Xui.Core.Math2D.Frame`](../xui-core-math2d/index.md#api-d08fc079b0a96833) with all sides set to `value`.

<a id="api-9f5183f28bfa4e94"></a>

### [`Frame.implicit operator Frame(NFloat value)`](#api-9f5183f28bfa4e94)


```csharp
[DebuggerStepThrough]
public static implicit operator Frame(nfloat value);
```

Converts a scalar value into a uniform [`Xui.Core.Math2D.Frame`](../xui-core-math2d/index.md#api-d08fc079b0a96833) for all sides.

<a id="api-e9c669eeb4134d47"></a>

### [`Frame.implicit operator Frame(float value)`](#api-e9c669eeb4134d47)


```csharp
[DebuggerStepThrough]
public static implicit operator Frame(float value);
```

Implicitly converts a `System.Single` to a [`Xui.Core.Math2D.Frame`](../xui-core-math2d/index.md#api-d08fc079b0a96833), applying the same value to all four sides (Left, Top, Right, Bottom).

- **`value`** — The float value to apply uniformly to all sides.

**Returns:** A [`Xui.Core.Math2D.Frame`](../xui-core-math2d/index.md#api-d08fc079b0a96833) with all sides set to `value`.

<a id="api-60b1941110d1d75b"></a>

### [`Frame.implicit operator Frame((NFloat top, NFloat right, NFloat bottom, NFloat left) value)`](#api-60b1941110d1d75b)


```csharp
[DebuggerStepThrough]
public static implicit operator Frame((nfloat top, nfloat right, nfloat bottom, nfloat left) value);
```

Converts a 4-tuple (top, right, bottom, left) to a [`Xui.Core.Math2D.Frame`](../xui-core-math2d/index.md#api-d08fc079b0a96833).

<a id="api-4489b60149ecaf8d"></a>

### [`Frame.implicit operator Frame((NFloat vertical, NFloat horizontal) value)`](#api-4489b60149ecaf8d)


```csharp
[DebuggerStepThrough]
public static implicit operator Frame((nfloat vertical, nfloat horizontal) value);
```

Converts a 2-tuple (horizontal, vertical) to a [`Xui.Core.Math2D.Frame`](../xui-core-math2d/index.md#api-d08fc079b0a96833). Horizontal is applied to left and right; vertical to top and bottom.

<a id="api-3e1c78df5130279a"></a>

### [`bool Frame.operator !=(Frame lhs, Frame rhs)`](#api-3e1c78df5130279a)


```csharp
public static bool operator !=(Frame lhs, Frame rhs);
```

Returns `true` if any edge value differs.

<a id="api-b4ca52f81d9a14fb"></a>

### [`Frame Frame.operator *(Frame lhs, NFloat rhs)`](#api-b4ca52f81d9a14fb)


```csharp
[DebuggerStepThrough]
public static Frame operator *(Frame lhs, nfloat rhs);
```

Scales all edges of the frame by the specified scalar.

<a id="api-5c57435e0d1f845a"></a>

### [`Frame Frame.operator -(Frame lhs, Frame rhs)`](#api-5c57435e0d1f845a)


```csharp
[DebuggerStepThrough]
public static Frame operator -(Frame lhs, Frame rhs);
```

Subtracts the corresponding edge thicknesses of two frames.


<a id="api-7dfbe8f77fb7adae"></a>

## `struct Point`

Represents a point in 2D space, defined by its [`Xui.Core.Math2D.Point.X`](../xui-core-math2d/index.md#api-a11389e161abb12c) and [`Xui.Core.Math2D.Point.Y`](../xui-core-math2d/index.md#api-34e4029aff82b767) coordinates.

```csharp
public struct Point
{
    public nfloat X;
    public nfloat Y;
    public static readonly Point Zero;
    public static readonly Point One;
    [DebuggerStepThrough]
    public Point(nfloat x, nfloat y);
    [DebuggerStepThrough]
    public static Point Lerp(Point start, Point end, nfloat step);
    [DebuggerStepThrough]
    public static nfloat Distance(Point a, Point b);
    [DebuggerStepThrough]
    public static nfloat SquaredDistance(Point a, Point b);
    [DebuggerStepThrough]
    public static nfloat TaxicabDistance(Point a, Point b);
    [DebuggerStepThrough]
    public static Vector operator -(Point lhs, Point rhs);
    [DebuggerStepThrough]
    public static Point operator +(Point lhs, Vector rhs);
    [DebuggerStepThrough]
    public static Point operator -(Point lhs, Vector rhs);
    [DebuggerStepThrough]
    public static implicit operator Point(ValueTuple<nfloat, nfloat> tuple);
    [DebuggerStepThrough]
    public static explicit operator Point(Vector vector);
    [DebuggerStepThrough]
    public static bool operator ==(Point lhs, Point rhs);
    [DebuggerStepThrough]
    public static bool operator !=(Point lhs, Point rhs);
    [DebuggerStepThrough]
    public static Point operator *(Point v, nfloat f);
    public override string ToString();
    public override bool Equals(object? obj);
    public bool Equals(Point other);
    public override int GetHashCode();
}
```

<a id="api-e8f6fd1f47c0d1fa"></a>

### [`Point.Point(NFloat x, NFloat y)`](#api-e8f6fd1f47c0d1fa)


```csharp
[DebuggerStepThrough]
public Point(nfloat x, nfloat y);
```

Initializes a new point with the specified coordinates.

<a id="api-f25ca597b70db593"></a>

### [`NFloat Point.Distance(Point a, Point b)`](#api-f25ca597b70db593)


```csharp
[DebuggerStepThrough]
public static nfloat Distance(Point a, Point b);
```

Returns the Euclidean distance between two points.

<a id="api-b37f1cac76bfbe98"></a>

### [`bool Point.Equals(object? obj)`](#api-b37f1cac76bfbe98)


```csharp
public override bool Equals(object? obj);
```

Indicates whether this instance and a specified object are equal.

- **`obj`** — The object to compare with the current instance.

**Returns:** `true` if `obj` and this instance are the same type and represent the same value; otherwise, `false`.

<a id="api-e8df8ca39229ff9a"></a>

### [`bool Point.Equals(Point other)`](#api-e8df8ca39229ff9a)


```csharp
public bool Equals(Point other);
```

Returns true if this point has the same coordinates as another.

<a id="api-dc2ad263ad7c7d50"></a>

### [`int Point.GetHashCode()`](#api-dc2ad263ad7c7d50)


```csharp
public override int GetHashCode();
```

Returns the hash code for this instance.

**Returns:** A 32-bit signed integer that is the hash code for this instance.

<a id="api-18da6fb256e3fbdb"></a>

### [`Point Point.Lerp(Point start, Point end, NFloat step)`](#api-18da6fb256e3fbdb)


```csharp
[DebuggerStepThrough]
public static Point Lerp(Point start, Point end, nfloat step);
```

Linearly interpolates between two points by `step`.

- **`start`** — The start point.

- **`end`** — The end point.

- **`step`** — A value from 0 to 1 indicating the interpolation position.

<a id="api-b1e08f1cdc336476"></a>

### [`Point Point.One`](#api-b1e08f1cdc336476)


```csharp
public static readonly Point One;
```

A point at (1, 1), useful for normalized coordinates or vector math.

<a id="api-c64a07312f071e75"></a>

### [`NFloat Point.SquaredDistance(Point a, Point b)`](#api-c64a07312f071e75)


```csharp
[DebuggerStepThrough]
public static nfloat SquaredDistance(Point a, Point b);
```

Returns the squared Euclidean distance between two points (no square root). Useful for performance comparisons or ordering by proximity.

<a id="api-1cbec009515aa6fd"></a>

### [`NFloat Point.TaxicabDistance(Point a, Point b)`](#api-1cbec009515aa6fd)


```csharp
[DebuggerStepThrough]
public static nfloat TaxicabDistance(Point a, Point b);
```

Returns the Manhattan (taxicab) distance between two points.

The sum of the absolute horizontal and vertical distances. Often used in grid-based or discrete movement systems.

<a id="api-6d27803c3c800920"></a>

### [`string Point.ToString()`](#api-6d27803c3c800920)


```csharp
public override string ToString();
```

Returns the fully qualified type name of this instance.

**Returns:** The fully qualified type name.

<a id="api-a11389e161abb12c"></a>

### [`NFloat Point.X`](#api-a11389e161abb12c)


```csharp
public nfloat X;
```

The X-coordinate of the point.

<a id="api-34e4029aff82b767"></a>

### [`NFloat Point.Y`](#api-34e4029aff82b767)


```csharp
public nfloat Y;
```

The Y-coordinate of the point.

<a id="api-0d43c18bef47613f"></a>

### [`Point Point.Zero`](#api-0d43c18bef47613f)


```csharp
public static readonly Point Zero;
```

A point at the origin (0, 0).

<a id="api-69c5276271fe1992"></a>

### [`Point Point.operator +(Point lhs, Vector rhs)`](#api-69c5276271fe1992)


```csharp
[DebuggerStepThrough]
public static Point operator +(Point lhs, Vector rhs);
```

Offsets a point by a vector.

<a id="api-77a0960f32047f7b"></a>

### [`bool Point.operator ==(Point lhs, Point rhs)`](#api-77a0960f32047f7b)


```csharp
[DebuggerStepThrough]
public static bool operator ==(Point lhs, Point rhs);
```

Determines whether two points have equal coordinates.

<a id="api-cf3f45e9b14937a4"></a>

### [`Point.explicit operator Point(Vector vector)`](#api-cf3f45e9b14937a4)


```csharp
[DebuggerStepThrough]
public static explicit operator Point(Vector vector);
```

Explicitly converts a vector to a point (drops directional semantics).

<a id="api-4fc641d494f19e4f"></a>

### [`Point.implicit operator Point((NFloat, NFloat) tuple)`](#api-4fc641d494f19e4f)


```csharp
[DebuggerStepThrough]
public static implicit operator Point(ValueTuple<nfloat, nfloat> tuple);
```

Converts a tuple to a point.

<a id="api-6a0c5745c74aa8be"></a>

### [`bool Point.operator !=(Point lhs, Point rhs)`](#api-6a0c5745c74aa8be)


```csharp
[DebuggerStepThrough]
public static bool operator !=(Point lhs, Point rhs);
```

Determines whether two points differ in any coordinate.

<a id="api-30b76c52379c5d1c"></a>

### [`Point Point.operator *(Point v, NFloat f)`](#api-30b76c52379c5d1c)


```csharp
[DebuggerStepThrough]
public static Point operator *(Point v, nfloat f);
```

Apply an uniform scale to a point.

<a id="api-83203dd7d99589cc"></a>

### [`Vector Point.operator -(Point lhs, Point rhs)`](#api-83203dd7d99589cc)


```csharp
[DebuggerStepThrough]
public static Vector operator -(Point lhs, Point rhs);
```

Returns the vector difference from one point to another.

<a id="api-9054cc0fe5a79e45"></a>

### [`Point Point.operator -(Point lhs, Vector rhs)`](#api-9054cc0fe5a79e45)


```csharp
[DebuggerStepThrough]
public static Point operator -(Point lhs, Vector rhs);
```

Subtracts a vector from a point, offsetting it in the opposite direction.


<a id="api-43aebae21ab1f31f"></a>

## `struct Rect`

Represents a rectangle in 2D space, defined by its origin ([`Xui.Core.Math2D.Rect.X`](../xui-core-math2d/index.md#api-e21e9e5a307f03c4), [`Xui.Core.Math2D.Rect.Y`](../xui-core-math2d/index.md#api-84e6f91361647ab2)) and its dimensions ([`Xui.Core.Math2D.Rect.Width`](../xui-core-math2d/index.md#api-131744b4aa58d6dc), [`Xui.Core.Math2D.Rect.Height`](../xui-core-math2d/index.md#api-3faf2365c21fb01b)).

Unlike [`Xui.Core.Math2D.Frame`](../xui-core-math2d/index.md#api-d08fc079b0a96833), which represents edge thicknesses around a box, [`Xui.Core.Math2D.Rect`](../xui-core-math2d/index.md#api-43aebae21ab1f31f) defines a positioned, sized area used for layout and rendering.

```csharp
public struct Rect : INonEnumerableSet<Point>, IEquatable<Rect>
{
    public nfloat X;
    public nfloat Y;
    public nfloat Width;
    public nfloat Height;
    [DebuggerStepThrough]
    public Rect(nfloat x, nfloat y, nfloat width, nfloat height);
    [DebuggerStepThrough]
    public Rect(Point topLeft, Size size);
    [DebuggerStepThrough]
    public Rect(Vector topLeft, Size size);
    [DebuggerBrowsable(DebuggerBrowsableState.Never)]
    public Point TopLeft { get; }

    [DebuggerBrowsable(DebuggerBrowsableState.Never)]
    public Point TopCenter { get; }

    [DebuggerBrowsable(DebuggerBrowsableState.Never)]
    public Point TopRight { get; }

    [DebuggerBrowsable(DebuggerBrowsableState.Never)]
    public Point BottomRight { get; }

    [DebuggerBrowsable(DebuggerBrowsableState.Never)]
    public Point BottomLeft { get; }

    [DebuggerBrowsable(DebuggerBrowsableState.Never)]
    public nfloat Left { get; }

    [DebuggerBrowsable(DebuggerBrowsableState.Never)]
    public nfloat Top { get; }

    [DebuggerBrowsable(DebuggerBrowsableState.Never)]
    public nfloat Right { get; }

    [DebuggerBrowsable(DebuggerBrowsableState.Never)]
    public nfloat Bottom { get; }
    public Point Center { get; }

    [DebuggerBrowsable(DebuggerBrowsableState.Never)]
    public Size Size { get; set; }

    [DebuggerStepThrough]
    public Rect Inset(nfloat inset);
    [DebuggerStepThrough]
    public bool Contains(Point point);
    [DebuggerStepThrough]
    public bool Intersects(Rect other);
    [DebuggerStepThrough]
    public Rect Expand(nfloat h, nfloat v);
    [DebuggerStepThrough]
    public Rect Expand(nfloat expand);
    [DebuggerStepThrough]
    public static implicit operator Rect(ValueTuple<nfloat, nfloat, nfloat, nfloat> tuple);
    [DebuggerStepThrough]
    public static Rect operator +(Rect rect, Frame frame);
    [DebuggerStepThrough]
    public static Rect operator -(Rect rect, Frame frame);
    [DebuggerStepThrough]
    public static bool operator ==(Rect lhs, Rect rhs);
    [DebuggerStepThrough]
    public static bool operator !=(Rect lhs, Rect rhs);
    public override bool Equals(object? obj);
    public bool Equals(Rect other);
    public override int GetHashCode();
    [DebuggerStepThrough]
    public override string ToString();
}
```

<a id="api-bd5f882dbd6771f4"></a>

### [`Rect.Rect(NFloat x, NFloat y, NFloat width, NFloat height)`](#api-bd5f882dbd6771f4)


```csharp
[DebuggerStepThrough]
public Rect(nfloat x, nfloat y, nfloat width, nfloat height);
```

Creates a new [`Xui.Core.Math2D.Rect`](../xui-core-math2d/index.md#api-43aebae21ab1f31f) from position and size.

<a id="api-2713054131b6cc05"></a>

### [`Rect.Rect(Point topLeft, Size size)`](#api-2713054131b6cc05)


```csharp
[DebuggerStepThrough]
public Rect(Point topLeft, Size size);
```

Creates a new [`Xui.Core.Math2D.Rect`](../xui-core-math2d/index.md#api-43aebae21ab1f31f) from a top-left point and a size.

<a id="api-8901118fe0d56e77"></a>

### [`Rect.Rect(Vector topLeft, Size size)`](#api-8901118fe0d56e77)


```csharp
[DebuggerStepThrough]
public Rect(Vector topLeft, Size size);
```

Creates a new [`Xui.Core.Math2D.Rect`](../xui-core-math2d/index.md#api-43aebae21ab1f31f) from a top-left vector and a size.

<a id="api-07c7b5e2ceddb8ac"></a>

### [`NFloat Rect.Bottom`](#api-07c7b5e2ceddb8ac)


```csharp
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public nfloat Bottom { get; }
```

Returns the Y-coordinate of the bottom edge.

<a id="api-02bcde83ef55930b"></a>

### [`Point Rect.BottomLeft`](#api-02bcde83ef55930b)


```csharp
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Point BottomLeft { get; }
```

Returns the bottom-left point of the rectangle.

<a id="api-790f663286061615"></a>

### [`Point Rect.BottomRight`](#api-790f663286061615)


```csharp
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Point BottomRight { get; }
```

Returns the bottom-right point of the rectangle.

<a id="api-e9985cea0283d8f5"></a>

### [`Point Rect.Center`](#api-e9985cea0283d8f5)


```csharp
public Point Center { get; }
```

Returns the center point of the rectangle.

<a id="api-7a58d3350d11962d"></a>

### [`bool Rect.Contains(Point point)`](#api-7a58d3350d11962d)


```csharp
[DebuggerStepThrough]
public bool Contains(Point point);
```

Returns true if the specified `point` lies within this rectangle.

<a id="api-0691c16b87cdb732"></a>

### [`bool Rect.Equals(object? obj)`](#api-0691c16b87cdb732)


```csharp
public override bool Equals(object? obj);
```

Indicates whether this instance and a specified object are equal.

- **`obj`** — The object to compare with the current instance.

**Returns:** `true` if `obj` and this instance are the same type and represent the same value; otherwise, `false`.

<a id="api-36b7eb57bb11e2a2"></a>

### [`bool Rect.Equals(Rect other)`](#api-36b7eb57bb11e2a2)


```csharp
public bool Equals(Rect other);
```

Returns true if this rectangle is equal to another rectangle in position and size.

<a id="api-7baa67117901bbd5"></a>

### [`Rect Rect.Expand(NFloat expand)`](#api-7baa67117901bbd5)


```csharp
[DebuggerStepThrough]
public Rect Expand(nfloat expand);
```

Returns a rectangle expanded uniformly in all directions.

<a id="api-7382f6a97f13c2e5"></a>

### [`Rect Rect.Expand(NFloat h, NFloat v)`](#api-7382f6a97f13c2e5)


```csharp
[DebuggerStepThrough]
public Rect Expand(nfloat h, nfloat v);
```

Returns a rectangle expanded horizontally and vertically by the specified amounts.

<a id="api-4f0641fe5923a3d8"></a>

### [`int Rect.GetHashCode()`](#api-4f0641fe5923a3d8)


```csharp
public override int GetHashCode();
```

Returns the hash code for this instance.

**Returns:** A 32-bit signed integer that is the hash code for this instance.

<a id="api-3faf2365c21fb01b"></a>

### [`NFloat Rect.Height`](#api-3faf2365c21fb01b)


```csharp
public nfloat Height;
```

The height of the rectangle.

<a id="api-8061d90583b6f8f5"></a>

### [`Rect Rect.Inset(NFloat inset)`](#api-8061d90583b6f8f5)


```csharp
[DebuggerStepThrough]
public Rect Inset(nfloat inset);
```

Returns a new rectangle that is inset by the same amount on all four sides.

<a id="api-9383b5580655825c"></a>

### [`bool Rect.Intersects(Rect other)`](#api-9383b5580655825c)


```csharp
[DebuggerStepThrough]
public bool Intersects(Rect other);
```

Returns whether this rectangle overlaps or touches `other`.

<a id="api-2b39d90afcab67f4"></a>

### [`NFloat Rect.Left`](#api-2b39d90afcab67f4)


```csharp
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public nfloat Left { get; }
```

Returns the X-coordinate of the left edge.

<a id="api-377f3120e1513b2b"></a>

### [`NFloat Rect.Right`](#api-377f3120e1513b2b)


```csharp
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public nfloat Right { get; }
```

Returns the X-coordinate of the right edge.

<a id="api-7a1b2783c1021d22"></a>

### [`Size Rect.Size`](#api-7a1b2783c1021d22)


```csharp
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Size Size { get; set; }
```

Gets or sets the size of the rectangle.

<a id="api-1b78f6bd9e8bf6d4"></a>

### [`string Rect.ToString()`](#api-1b78f6bd9e8bf6d4)


```csharp
[DebuggerStepThrough]
public override string ToString();
```

Returns the fully qualified type name of this instance.

**Returns:** The fully qualified type name.

<a id="api-23034af5c15e9372"></a>

### [`NFloat Rect.Top`](#api-23034af5c15e9372)


```csharp
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public nfloat Top { get; }
```

Returns the Y-coordinate of the top edge.

<a id="api-136796c79bec9677"></a>

### [`Point Rect.TopCenter`](#api-136796c79bec9677)


```csharp
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Point TopCenter { get; }
```

Returns the top-center point of the rectangle.

<a id="api-eb5113d1269398f0"></a>

### [`Point Rect.TopLeft`](#api-eb5113d1269398f0)


```csharp
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Point TopLeft { get; }
```

Returns the top-left point of the rectangle.

<a id="api-55bf44646c5eac72"></a>

### [`Point Rect.TopRight`](#api-55bf44646c5eac72)


```csharp
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Point TopRight { get; }
```

Returns the top-right point of the rectangle.

<a id="api-131744b4aa58d6dc"></a>

### [`NFloat Rect.Width`](#api-131744b4aa58d6dc)


```csharp
public nfloat Width;
```

The width of the rectangle.

<a id="api-e21e9e5a307f03c4"></a>

### [`NFloat Rect.X`](#api-e21e9e5a307f03c4)


```csharp
public nfloat X;
```

The X-coordinate of the rectangle’s top-left corner.

<a id="api-84e6f91361647ab2"></a>

### [`NFloat Rect.Y`](#api-84e6f91361647ab2)


```csharp
public nfloat Y;
```

The Y-coordinate of the rectangle’s top-left corner.

<a id="api-a9979511eac84a1d"></a>

### [`Rect Rect.operator +(Rect rect, Frame frame)`](#api-a9979511eac84a1d)


```csharp
[DebuggerStepThrough]
public static Rect operator +(Rect rect, Frame frame);
```

Returns a rectangle expanded outward by a [`Xui.Core.Math2D.Frame`](../xui-core-math2d/index.md#api-d08fc079b0a96833).

<a id="api-99c9bb0c65e947cd"></a>

### [`bool Rect.operator ==(Rect lhs, Rect rhs)`](#api-99c9bb0c65e947cd)


```csharp
[DebuggerStepThrough]
public static bool operator ==(Rect lhs, Rect rhs);
```

Returns true if two rectangles are equal in position and size.

<a id="api-daf51e63dd2407e4"></a>

### [`Rect.implicit operator Rect((NFloat, NFloat, NFloat, NFloat) tuple)`](#api-daf51e63dd2407e4)


```csharp
[DebuggerStepThrough]
public static implicit operator Rect(ValueTuple<nfloat, nfloat, nfloat, nfloat> tuple);
```

Implicit conversion from a 4-tuple to a rectangle.

<a id="api-d0564c3fa8d8dce4"></a>

### [`bool Rect.operator !=(Rect lhs, Rect rhs)`](#api-d0564c3fa8d8dce4)


```csharp
[DebuggerStepThrough]
public static bool operator !=(Rect lhs, Rect rhs);
```

Returns true if any of the rectangle fields are different.

<a id="api-53b62e4a788c6f6f"></a>

### [`Rect Rect.operator -(Rect rect, Frame frame)`](#api-53b62e4a788c6f6f)


```csharp
[DebuggerStepThrough]
public static Rect operator -(Rect rect, Frame frame);
```

Returns a rectangle inset inward by a [`Xui.Core.Math2D.Frame`](../xui-core-math2d/index.md#api-d08fc079b0a96833).


<a id="api-348aa93314a72466"></a>

## `struct Size`

Represents a two-dimensional size with [`Xui.Core.Math2D.Size.Width`](../xui-core-math2d/index.md#api-8590ddca48e3476d) and [`Xui.Core.Math2D.Size.Height`](../xui-core-math2d/index.md#api-c265666d31d67512) components.

A [`Xui.Core.Math2D.Size`](../xui-core-math2d/index.md#api-348aa93314a72466) specifies how much space an element occupies, without defining its position. It is commonly used in layout systems to describe constraints or measured results.

```csharp
public struct Size
{
    public nfloat Width;
    public nfloat Height;
    public static readonly Size Empty;
    public static readonly Size Infinity;
    [DebuggerStepThrough]
    public Size();
    [DebuggerStepThrough]
    public Size(nfloat width, nfloat height);
    [DebuggerStepThrough]
    public static implicit operator Size(ValueTuple<nfloat, nfloat> tuple);
    public static implicit operator Size(int uniform);
    [DebuggerStepThrough]
    public static explicit operator Size(Vector vector);
    [DebuggerStepThrough]
    public static Size operator +(Size size, Frame frame);
    [DebuggerStepThrough]
    public static Size operator -(Size size, Frame frame);
    [DebuggerStepThrough]
    public static Size operator +(Size lhs, Size rhs);
    [DebuggerStepThrough]
    public override string ToString();
    [DebuggerStepThrough]
    public static bool operator ==(Size lhs, Size rhs);
    [DebuggerStepThrough]
    public static bool operator !=(Size lhs, Size rhs);
    [DebuggerStepThrough]
    public override bool Equals(object? obj);
    public bool Equals(Size other);
    [DebuggerStepThrough]
    public override int GetHashCode();
    public static Size Min(Size lhs, Size rhs);
    public static Size Max(Size lhs, Size rhs);
}
```

<a id="api-7ecf0f99ea9faad5"></a>

### [`Size.Size()`](#api-7ecf0f99ea9faad5)


```csharp
[DebuggerStepThrough]
public Size();
```

Initializes a new instance of the [`Xui.Core.Math2D.Size`](../xui-core-math2d/index.md#api-348aa93314a72466) struct with zero dimensions.

<a id="api-345e6d61eecdfc5f"></a>

### [`Size.Size(NFloat width, NFloat height)`](#api-345e6d61eecdfc5f)


```csharp
[DebuggerStepThrough]
public Size(nfloat width, nfloat height);
```

Initializes a new instance of the [`Xui.Core.Math2D.Size`](../xui-core-math2d/index.md#api-348aa93314a72466) struct with the given width and height.

- **`width`** — The width of the size.

- **`height`** — The height of the size.

<a id="api-89bf9ed1f6720fde"></a>

### [`Size Size.Empty`](#api-89bf9ed1f6720fde)


```csharp
public static readonly Size Empty;
```

A size with zero width and height.

<a id="api-ee34ac874f88b413"></a>

### [`bool Size.Equals(object? obj)`](#api-ee34ac874f88b413)


```csharp
[DebuggerStepThrough]
public override bool Equals(object? obj);
```

Indicates whether this instance and a specified object are equal.

- **`obj`** — The object to compare with the current instance.

**Returns:** `true` if `obj` and this instance are the same type and represent the same value; otherwise, `false`.

<a id="api-362f1b726160685b"></a>

### [`bool Size.Equals(Size other)`](#api-362f1b726160685b)


```csharp
public bool Equals(Size other);
```

Returns `true` if this size is equal to the specified `other`.

<a id="api-ae29d1a5d6d44d4b"></a>

### [`int Size.GetHashCode()`](#api-ae29d1a5d6d44d4b)


```csharp
[DebuggerStepThrough]
public override int GetHashCode();
```

Returns the hash code for this instance.

**Returns:** A 32-bit signed integer that is the hash code for this instance.

<a id="api-c265666d31d67512"></a>

### [`NFloat Size.Height`](#api-c265666d31d67512)


```csharp
public nfloat Height;
```

The height of the element.

<a id="api-f87a66ec8353ede8"></a>

### [`Size Size.Infinity`](#api-f87a66ec8353ede8)


```csharp
public static readonly Size Infinity;
```

A size with infinite width and height.

<a id="api-1ab3bafd29fade27"></a>

### [`Size Size.Max(Size lhs, Size rhs)`](#api-1ab3bafd29fade27)


```csharp
public static Size Max(Size lhs, Size rhs);
```

Returns the maximum of two sizes, using the larger width and height from each.

<a id="api-a0271e5bb1b76d68"></a>

### [`Size Size.Min(Size lhs, Size rhs)`](#api-a0271e5bb1b76d68)


```csharp
public static Size Min(Size lhs, Size rhs);
```

Returns the minimum of two sizes, using the smaller width and height from each.

<a id="api-c292729dbcf686bd"></a>

### [`string Size.ToString()`](#api-c292729dbcf686bd)


```csharp
[DebuggerStepThrough]
public override string ToString();
```

Returns the fully qualified type name of this instance.

**Returns:** The fully qualified type name.

<a id="api-8590ddca48e3476d"></a>

### [`NFloat Size.Width`](#api-8590ddca48e3476d)


```csharp
public nfloat Width;
```

The width of the element.

<a id="api-d19a74d766b33ff3"></a>

### [`Size Size.operator +(Size size, Frame frame)`](#api-d19a74d766b33ff3)


```csharp
[DebuggerStepThrough]
public static Size operator +(Size size, Frame frame);
```

Adds edge spacing from a [`Xui.Core.Math2D.Frame`](../xui-core-math2d/index.md#api-d08fc079b0a96833) to a [`Xui.Core.Math2D.Size`](../xui-core-math2d/index.md#api-348aa93314a72466), increasing its dimensions.

<a id="api-5af9e76f6fc48d72"></a>

### [`Size Size.operator +(Size lhs, Size rhs)`](#api-5af9e76f6fc48d72)


```csharp
[DebuggerStepThrough]
public static Size operator +(Size lhs, Size rhs);
```

Adds two sizes together component-wise.

<a id="api-edaf2c9fc83d99ac"></a>

### [`bool Size.operator ==(Size lhs, Size rhs)`](#api-edaf2c9fc83d99ac)


```csharp
[DebuggerStepThrough]
public static bool operator ==(Size lhs, Size rhs);
```

Returns `true` if the two sizes have the same dimensions.

<a id="api-21530fee7d06b410"></a>

### [`Size.explicit operator Size(Vector vector)`](#api-21530fee7d06b410)


```csharp
[DebuggerStepThrough]
public static explicit operator Size(Vector vector);
```

Explicitly converts a [`Xui.Core.Math2D.Vector`](../xui-core-math2d/index.md#api-dc51b72f122240f1) to a [`Xui.Core.Math2D.Size`](../xui-core-math2d/index.md#api-348aa93314a72466).

<a id="api-ad91ae17bbf39590"></a>

### [`Size.implicit operator Size(int uniform)`](#api-ad91ae17bbf39590)


```csharp
public static implicit operator Size(int uniform);
```

Returns the size of a square.

<a id="api-8afe4cbd209aa45e"></a>

### [`Size.implicit operator Size((NFloat, NFloat) tuple)`](#api-8afe4cbd209aa45e)


```csharp
[DebuggerStepThrough]
public static implicit operator Size(ValueTuple<nfloat, nfloat> tuple);
```

Implicitly converts a tuple to a [`Xui.Core.Math2D.Size`](../xui-core-math2d/index.md#api-348aa93314a72466).

<a id="api-3c1c6539a273ff3a"></a>

### [`bool Size.operator !=(Size lhs, Size rhs)`](#api-3c1c6539a273ff3a)


```csharp
[DebuggerStepThrough]
public static bool operator !=(Size lhs, Size rhs);
```

Returns `true` if the two sizes have different dimensions.

<a id="api-db0edd5e09d2bcc9"></a>

### [`Size Size.operator -(Size size, Frame frame)`](#api-db0edd5e09d2bcc9)


```csharp
[DebuggerStepThrough]
public static Size operator -(Size size, Frame frame);
```

Subtracts edge spacing from a [`Xui.Core.Math2D.Size`](../xui-core-math2d/index.md#api-348aa93314a72466), reducing its dimensions.


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

## `struct Vector`

Represents a 2D vector with X and Y components, commonly used for geometric operations, layout math, and movement in 2D space.

```csharp
public struct Vector
{
    public nfloat X;
    public nfloat Y;
    [DebuggerStepThrough]
    public Vector(nfloat x, nfloat y);
    public static readonly Vector Zero;
    public static readonly Vector One;
    public static readonly Vector Left;
    public static readonly Vector Up;
    public static readonly Vector Right;
    public static readonly Vector Down;
    public Vector Normalized { get; }
    public Vector PerpendicularCCW { get; }
    public Vector PerpendicularCW { get; }
    public nfloat Magnitude { get; }
    public nfloat Length { get; }
    public nfloat MagnitudeSquared { get; }
    public nfloat ArcAngle { get; }

    public Vector Rotate(nfloat degrees);
    [DebuggerStepThrough]
    public static nfloat Dot(Vector lhs, Vector rhs);
    [DebuggerStepThrough]
    public static Vector Project(Vector lhs, Vector rhs);
    [DebuggerStepThrough]
    public static nfloat Cross(Vector lhs, Vector rhs);
    [DebuggerStepThrough]
    public Vector Clamp(nfloat max);
    [DebuggerStepThrough]
    public static nfloat Angle(Vector v);
    [DebuggerStepThrough]
    public static Vector Angle(nfloat radians);
    [DebuggerStepThrough]
    public static nfloat Angle(Vector lhs, Vector rhs);
    [DebuggerStepThrough]
    public static Vector Lerp(Vector start, Vector end, nfloat step);
    [DebuggerStepThrough]
    public static implicit operator Vector(Point point);
    [DebuggerStepThrough]
    public static Vector operator *(Vector v, nfloat f);
    [DebuggerStepThrough]
    public static Vector operator /(Vector v, nfloat f);
    [DebuggerStepThrough]
    public static Vector operator *(nfloat f, Vector v);
    [DebuggerStepThrough]
    public static Vector operator +(Vector lhs, Vector rhs);
    [DebuggerStepThrough]
    public static Vector operator -(Vector lhs, Vector rhs);
    [DebuggerStepThrough]
    public static implicit operator Vector(ValueTuple<nfloat, nfloat> tuple);
    [DebuggerStepThrough]
    public static bool operator ==(Vector lhs, Vector rhs);
    [DebuggerStepThrough]
    public static bool operator !=(Vector lhs, Vector rhs);
    public override bool Equals(object? obj);
    public bool Equals(Vector other);
    public override int GetHashCode();
    public override string ToString();
}
```

<a id="api-8504ee4941440b38"></a>

### [`Vector.Vector(NFloat x, NFloat y)`](#api-8504ee4941440b38)


```csharp
[DebuggerStepThrough]
public Vector(nfloat x, nfloat y);
```

Initializes a new instance of the [`Xui.Core.Math2D.Vector`](../xui-core-math2d/index.md#api-dc51b72f122240f1) struct with the specified X and Y components.

- **`x`** — The horizontal component of the vector.

- **`y`** — The vertical component of the vector.

<a id="api-e1fd5b9d4995374c"></a>

### [`Vector Vector.Angle(NFloat radians)`](#api-e1fd5b9d4995374c)


```csharp
[DebuggerStepThrough]
public static Vector Angle(nfloat radians);
```

Returns a unit vector rotated clockwise from the upward direction (0, 1) by the given angle (in radians).

<a id="api-eb50cf6bc80216fb"></a>

### [`NFloat Vector.Angle(Vector v)`](#api-eb50cf6bc80216fb)


```csharp
[DebuggerStepThrough]
public static nfloat Angle(Vector v);
```

Returns the clockwise angle (in radians) from the upward direction (0, 1) to the given vector.

<a id="api-e96ce5e14367d25c"></a>

### [`NFloat Vector.Angle(Vector lhs, Vector rhs)`](#api-e96ce5e14367d25c)


```csharp
[DebuggerStepThrough]
public static nfloat Angle(Vector lhs, Vector rhs);
```

Returns the signed angle (in radians) from `lhs` to `rhs`, clockwise from upward.

<a id="api-010b843aec3fa50b"></a>

### [`NFloat Vector.ArcAngle`](#api-010b843aec3fa50b)


```csharp
public nfloat ArcAngle { get; }
```

Gets the angle in radians between the vector and the positive X-axis, measured counter-clockwise in the range [-π, π].

This is equivalent to calling `Atan2(Y, X)` and is commonly used to compute polar angles from directional vectors, such as when determining the angular position of a point on a circle or ellipse.

**Returns:** The angle in radians between this vector and the X-axis.

<a id="api-996e85e65c59d74d"></a>

### [`Vector Vector.Clamp(NFloat max)`](#api-996e85e65c59d74d)


```csharp
[DebuggerStepThrough]
public Vector Clamp(nfloat max);
```

Returns a new vector with its magnitude limited to the specified maximum.

<a id="api-a150b85f967121d7"></a>

### [`NFloat Vector.Cross(Vector lhs, Vector rhs)`](#api-a150b85f967121d7)


```csharp
[DebuggerStepThrough]
public static nfloat Cross(Vector lhs, Vector rhs);
```

Returns the 2D cross product (scalar) of two vectors.

<a id="api-03240e966dc61841"></a>

### [`NFloat Vector.Dot(Vector lhs, Vector rhs)`](#api-03240e966dc61841)


```csharp
[DebuggerStepThrough]
public static nfloat Dot(Vector lhs, Vector rhs);
```

Returns the dot product of two vectors.

<a id="api-5b607eee3f943caa"></a>

### [`Vector Vector.Down`](#api-5b607eee3f943caa)


```csharp
public static readonly Vector Down;
```

A unit vector pointing down (0, 1).

<a id="api-27adf05164b35ea1"></a>

### [`bool Vector.Equals(object? obj)`](#api-27adf05164b35ea1)


```csharp
public override bool Equals(object? obj);
```

Indicates whether this instance and a specified object are equal.

- **`obj`** — The object to compare with the current instance.

**Returns:** `true` if `obj` and this instance are the same type and represent the same value; otherwise, `false`.

<a id="api-7b17393c4c62faef"></a>

### [`bool Vector.Equals(Vector other)`](#api-7b17393c4c62faef)


```csharp
public bool Equals(Vector other);
```

Returns true if this vector is equal to another vector.

<a id="api-0db090210ae91970"></a>

### [`int Vector.GetHashCode()`](#api-0db090210ae91970)


```csharp
public override int GetHashCode();
```

Returns the hash code for this instance.

**Returns:** A 32-bit signed integer that is the hash code for this instance.

<a id="api-77e9b7dae2e65d08"></a>

### [`Vector Vector.Left`](#api-77e9b7dae2e65d08)


```csharp
public static readonly Vector Left;
```

A unit vector pointing left (-1, 0).

<a id="api-7ed2089040635bc4"></a>

### [`NFloat Vector.Length`](#api-7ed2089040635bc4)


```csharp
public nfloat Length { get; }
```

Returns the magnitude (length) of the vector.

<a id="api-0f5379fc4ad461aa"></a>

### [`Vector Vector.Lerp(Vector start, Vector end, NFloat step)`](#api-0f5379fc4ad461aa)


```csharp
[DebuggerStepThrough]
public static Vector Lerp(Vector start, Vector end, nfloat step);
```

Linearly interpolates between two vectors by `step`.

<a id="api-5e726bd0fc84b720"></a>

### [`NFloat Vector.Magnitude`](#api-5e726bd0fc84b720)


```csharp
public nfloat Magnitude { get; }
```

Returns the magnitude (length) of the vector.

<a id="api-b682916f1309fe50"></a>

### [`NFloat Vector.MagnitudeSquared`](#api-b682916f1309fe50)


```csharp
public nfloat MagnitudeSquared { get; }
```

Returns the squared magnitude (length squared) of the vector. This avoids the square root computation used in [`Xui.Core.Math2D.Vector.Magnitude`](../xui-core-math2d/index.md#api-5e726bd0fc84b720).

<a id="api-d1acd7da003280f6"></a>

### [`Vector Vector.Normalized`](#api-d1acd7da003280f6)


```csharp
public Vector Normalized { get; }
```

Returns a normalized (unit length) version of this vector.

<a id="api-28c1f5d3c89d77d5"></a>

### [`Vector Vector.One`](#api-28c1f5d3c89d77d5)


```csharp
public static readonly Vector One;
```

A unit vector (1, 1).

<a id="api-d2c4b9de1da1fc55"></a>

### [`Vector Vector.PerpendicularCCW`](#api-d2c4b9de1da1fc55)


```csharp
public Vector PerpendicularCCW { get; }
```

Returns the vector rotated 90&#176; counter-clockwise (CCW).

<a id="api-8de4b9bd1dd1088a"></a>

### [`Vector Vector.PerpendicularCW`](#api-8de4b9bd1dd1088a)


```csharp
public Vector PerpendicularCW { get; }
```

Returns the vector rotated 90&#176; clockwise (CW).

<a id="api-1f9912d46082fec5"></a>

### [`Vector Vector.Project(Vector lhs, Vector rhs)`](#api-1f9912d46082fec5)


```csharp
[DebuggerStepThrough]
public static Vector Project(Vector lhs, Vector rhs);
```

Projects `lhs` onto `rhs`.

<a id="api-a2e3ff32cbeaba12"></a>

### [`Vector Vector.Right`](#api-a2e3ff32cbeaba12)


```csharp
public static readonly Vector Right;
```

A unit vector pointing right (1, 0).

<a id="api-fcb2083c1ea3f9fd"></a>

### [`Vector Vector.Rotate(NFloat degrees)`](#api-fcb2083c1ea3f9fd)


```csharp
public Vector Rotate(nfloat degrees);
```

Rotates the vector counterclockwise by the given angle (in degrees).

<a id="api-14415be7912f01b7"></a>

### [`string Vector.ToString()`](#api-14415be7912f01b7)


```csharp
public override string ToString();
```

Returns the fully qualified type name of this instance.

**Returns:** The fully qualified type name.

<a id="api-9e74754d62d2ea96"></a>

### [`Vector Vector.Up`](#api-9e74754d62d2ea96)


```csharp
public static readonly Vector Up;
```

A unit vector pointing up (0, -1).

<a id="api-b9869122d27a0b97"></a>

### [`NFloat Vector.X`](#api-b9869122d27a0b97)


```csharp
public nfloat X;
```

The horizontal component of the vector.

<a id="api-aa45a39f61c8f7d4"></a>

### [`NFloat Vector.Y`](#api-aa45a39f61c8f7d4)


```csharp
public nfloat Y;
```

The vertical component of the vector.

<a id="api-06cb413f1f76e4c5"></a>

### [`Vector Vector.Zero`](#api-06cb413f1f76e4c5)


```csharp
public static readonly Vector Zero;
```

A zero vector (0, 0).

<a id="api-aec68e4ab3bcd9fd"></a>

### [`Vector Vector.operator +(Vector lhs, Vector rhs)`](#api-aec68e4ab3bcd9fd)


```csharp
[DebuggerStepThrough]
public static Vector operator +(Vector lhs, Vector rhs);
```

Adds two vectors.

<a id="api-114dfa6e6ae56a86"></a>

### [`Vector Vector.operator /(Vector v, NFloat f)`](#api-114dfa6e6ae56a86)


```csharp
[DebuggerStepThrough]
public static Vector operator /(Vector v, nfloat f);
```

Divides a vector by a scalar.

<a id="api-4b322b2cc424cb4e"></a>

### [`bool Vector.operator ==(Vector lhs, Vector rhs)`](#api-4b322b2cc424cb4e)


```csharp
[DebuggerStepThrough]
public static bool operator ==(Vector lhs, Vector rhs);
```

Returns true if the two vectors have equal components.

<a id="api-02a7e32c6576f2c4"></a>

### [`Vector.implicit operator Vector((NFloat, NFloat) tuple)`](#api-02a7e32c6576f2c4)


```csharp
[DebuggerStepThrough]
public static implicit operator Vector(ValueTuple<nfloat, nfloat> tuple);
```

Implicitly converts a tuple to a [`Xui.Core.Math2D.Vector`](../xui-core-math2d/index.md#api-dc51b72f122240f1).

<a id="api-30063999678c0dcb"></a>

### [`Vector.implicit operator Vector(Point point)`](#api-30063999678c0dcb)


```csharp
[DebuggerStepThrough]
public static implicit operator Vector(Point point);
```

Implicitly converts a [`Xui.Core.Math2D.Point`](../xui-core-math2d/index.md#api-7dfbe8f77fb7adae) to a [`Xui.Core.Math2D.Vector`](../xui-core-math2d/index.md#api-dc51b72f122240f1).

<a id="api-f49a63dffc6ede90"></a>

### [`bool Vector.operator !=(Vector lhs, Vector rhs)`](#api-f49a63dffc6ede90)


```csharp
[DebuggerStepThrough]
public static bool operator !=(Vector lhs, Vector rhs);
```

Returns true if any component of the two vectors is different.

<a id="api-6d0587f8bef9d4e6"></a>

### [`Vector Vector.operator *(NFloat f, Vector v)`](#api-6d0587f8bef9d4e6)


```csharp
[DebuggerStepThrough]
public static Vector operator *(nfloat f, Vector v);
```

Multiplies a scalar by a vector.

<a id="api-f149399ecd13e0eb"></a>

### [`Vector Vector.operator *(Vector v, NFloat f)`](#api-f149399ecd13e0eb)


```csharp
[DebuggerStepThrough]
public static Vector operator *(Vector v, nfloat f);
```

Multiplies a vector by a scalar.

<a id="api-c9a6d3abbe494e69"></a>

### [`Vector Vector.operator -(Vector lhs, Vector rhs)`](#api-c9a6d3abbe494e69)


```csharp
[DebuggerStepThrough]
public static Vector operator -(Vector lhs, Vector rhs);
```

Subtracts one vector from another.

