// Generated API outline. Implementation bodies omitted. #nullable enable using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Net.Http; using System.Threading.Tasks; using System.Threading; using System; using nfloat = System.Runtime.InteropServices.NFloat; using static Xui.Core.Math2D.Constants; namespace Xui.Core.Math2D { /// /// Represents a 2D affine transformation matrix in the form: /// /// | A C Tx | /// | B D Ty | /// | 0 0 1 | /// /// Used for rotating, scaling, translating, and skewing 2D vectors or points. /// /// /// Transformation is applied as: /// /// | x' | | A C Tx | | x | /// | y' | = | B D Ty | * | y | /// | 1 | | 0 0 1 | | 1 | /// public struct AffineTransform { /// The matrix component in the first row, first column (scale X / rotate). public nfloat A; /// The matrix component in the second row, first column (shear Y / rotate). public nfloat B; /// The matrix component in the first row, second column (shear X / rotate). public nfloat C; /// The matrix component in the second row, second column (scale Y / rotate). public nfloat D; /// The translation component along the X axis. public nfloat Tx; /// The translation component along the Y axis. public nfloat Ty; /// The identity transform (no scale, rotation, or translation). public static readonly AffineTransform Identity; /// Returns true if the current transform is the identity matrix. public bool IsIdentity { 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. /// public AffineTransform Inverse {[DebuggerStepThrough] get; } /// /// Returns the determinant of the 2×2 linear portion of the matrix. /// /// /// This value determines if the matrix is invertible. A value of 0 means the matrix cannot be inverted. /// public nfloat Determinant {[DebuggerStepThrough] get; } /// /// Creates a rotation transform around the origin using the given angle in radians. /// [DebuggerStepThrough] public static AffineTransform Rotate(nfloat angle); /// /// Creates a translation transform using the specified offset vector. /// [DebuggerStepThrough] public static AffineTransform Translate(Vector v); /// /// Creates a scaling transform using the specified scale vector. /// [DebuggerStepThrough] public static AffineTransform Scale(Vector v); /// /// Creates a shear (skew) transformation along the X and Y axes. /// /// The shear factor in the X direction. /// The shear factor in the Y direction. [DebuggerStepThrough] public static AffineTransform Shear(nfloat shearX, nfloat shearY); /// /// Constructs an affine transform with the specified matrix coefficients. /// [DebuggerStepThrough] public AffineTransform(nfloat a, nfloat b, nfloat c, nfloat d, nfloat tx, nfloat ty); /// /// Applies only the linear portion (scale, rotation, shear) of this transform to a . /// /// /// Translation is not applied. Use this to transform directions, movement deltas, or normals. /// /// The affine transform. /// The vector to transform. /// A new with the linear transform applied. [DebuggerStepThrough] public static Vector operator *(AffineTransform t, Vector v); /// /// Applies this transform to a , 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's position). /// /// The affine transform. /// The point to transform. /// A new with the transform applied. [DebuggerStepThrough] public static Point operator *(AffineTransform t, Point p); /// /// Composes two affine transforms using matrix multiplication. /// /// A new transform representing the application of followed by . [DebuggerStepThrough] public static AffineTransform operator *(AffineTransform lhs, AffineTransform rhs); /// Returns the fully qualified type name of this instance. /// The fully qualified type name. [DebuggerStepThrough] public override string ToString(); } /// /// Common mathematical constants used throughout 2D geometry and curve computations. /// public static class Constants { /// π (pi): Ratio of a circle’s circumference to its diameter. public static readonly nfloat π; /// τ (tau): One full circle in radians (2π). public static readonly nfloat τ; /// ε (epsilon): A small value used for numerical stability checks. public static readonly nfloat ε; /// √2 (square root of 2): Diagonal of a unit square. public static readonly nfloat sqrt2; /// ϕ (phi): The golden ratio (≈ 1.618). public static readonly nfloat ϕ; } /// /// Represents thickness values for each edge of a rectangular element. /// /// /// A defines spacing from the left, top, right, and bottom edges. /// It is typically used for layout constructs such as Margin, Padding, or BorderWidth. /// Unlike , it does not represent position or size—only edge offsets. /// public struct Frame { /// The thickness of the top edge. public nfloat Top; /// The thickness of the right edge. public nfloat Right; /// The thickness of the bottom edge. public nfloat Bottom; /// The thickness of the left edge. public nfloat Left; /// /// Returns true if all four edges have equal thickness. /// public bool IsUniform { get; } /// /// Returns true if all sides (Left, Top, Right, Bottom) are zero. /// public readonly bool IsZero { get; } /// /// Gets the total horizontal edge thickness (left + right). /// public nfloat TotalWidth { get; } /// /// Gets the total vertical edge thickness (top + bottom). /// public nfloat TotalHeight { get; } /// /// A frame with all edge values set to zero. /// public static readonly Frame Zero; /// /// Initializes a new with all edges set to zero. /// [DebuggerStepThrough] public Frame(); /// /// Initializes a new with the specified edge thicknesses. /// /// Top edge thickness. /// Right edge thickness. /// Bottom edge thickness. /// Left edge thickness. [DebuggerStepThrough] public Frame(nfloat top, nfloat right, nfloat bottom, nfloat left); /// /// Converts a 4-tuple (top, right, bottom, left) to a . /// [DebuggerStepThrough] public static implicit operator Frame((nfloat top, nfloat right, nfloat bottom, nfloat left) value); /// /// Converts a 2-tuple (horizontal, vertical) to a . /// Horizontal is applied to left and right; vertical to top and bottom. /// [DebuggerStepThrough] public static implicit operator Frame((nfloat vertical, nfloat horizontal) value); /// /// Converts a scalar value into a uniform for all sides. /// [DebuggerStepThrough] public static implicit operator Frame(nfloat value); /// /// Implicitly converts an to a , /// applying the same value to all four sides (Left, Top, Right, Bottom). /// /// The integer value to apply uniformly to all sides. /// A with all sides set to . [DebuggerStepThrough] public static implicit operator Frame(int value); /// /// Implicitly converts a to a , /// applying the same value to all four sides (Left, Top, Right, Bottom). /// /// The double value to apply uniformly to all sides. /// A with all sides set to . [DebuggerStepThrough] public static implicit operator Frame(double value); /// /// Implicitly converts a to a , /// applying the same value to all four sides (Left, Top, Right, Bottom). /// /// The float value to apply uniformly to all sides. /// A with all sides set to . [DebuggerStepThrough] public static implicit operator Frame(float value); /// /// Scales all edges of the frame by the specified scalar. /// [DebuggerStepThrough] public static Frame operator *(Frame lhs, nfloat rhs); /// /// Adds the corresponding edge thicknesses of two frames. /// [DebuggerStepThrough] public static Frame operator +(Frame lhs, Frame rhs); /// /// Subtracts the corresponding edge thicknesses of two frames. /// [DebuggerStepThrough] public static Frame operator -(Frame lhs, Frame rhs); /// /// Returns a frame containing the maximum value for each edge from two frames. /// [DebuggerStepThrough] public static Frame Max(Frame lhs, Frame rhs); /// /// Returns a frame containing the minimum value for each edge from two frames. /// [DebuggerStepThrough] public static Frame Min(Frame lhs, Frame rhs); /// Returns the fully qualified type name of this instance. /// The fully qualified type name. [DebuggerStepThrough] public override string ToString(); /// /// Returns true if all edge values match exactly. /// public static bool operator ==(Frame left, Frame right); /// /// Returns true if any edge value differs. /// public static bool operator !=(Frame lhs, Frame rhs); /// Indicates whether this instance and a specified object are equal. /// The object to compare with the current instance. /// /// if and this instance are the same type and represent the same value; otherwise, . public override bool Equals(object? obj); /// Returns the hash code for this instance. /// A 32-bit signed integer that is the hash code for this instance. public override int GetHashCode(); } /// /// Represents a two-dimensional size with and components. /// /// /// A specifies how much space an element occupies, without defining its position. /// It is commonly used in layout systems to describe constraints or measured results. /// public struct Size { /// The width of the element. public nfloat Width; /// The height of the element. public nfloat Height; /// A size with zero width and height. public static readonly Size Empty; /// A size with infinite width and height. public static readonly Size Infinity; /// /// Initializes a new instance of the struct with zero dimensions. /// [DebuggerStepThrough] public Size(); /// /// Initializes a new instance of the struct with the given width and height. /// /// The width of the size. /// The height of the size. [DebuggerStepThrough] public Size(nfloat width, nfloat height); /// /// Implicitly converts a tuple to a . /// [DebuggerStepThrough] public static implicit operator Size(ValueTuple tuple); /// /// Returns the size of a square. /// public static implicit operator Size(int uniform); /// /// Explicitly converts a to a . /// [DebuggerStepThrough] public static explicit operator Size(Vector vector); /// /// Adds edge spacing from a to a , increasing its dimensions. /// [DebuggerStepThrough] public static Size operator +(Size size, Frame frame); /// /// Subtracts edge spacing from a , reducing its dimensions. /// [DebuggerStepThrough] public static Size operator -(Size size, Frame frame); /// /// Adds two sizes together component-wise. /// [DebuggerStepThrough] public static Size operator +(Size lhs, Size rhs); /// Returns the fully qualified type name of this instance. /// The fully qualified type name. [DebuggerStepThrough] public override string ToString(); /// /// Returns true if the two sizes have the same dimensions. /// [DebuggerStepThrough] public static bool operator ==(Size lhs, Size rhs); /// /// Returns true if the two sizes have different dimensions. /// [DebuggerStepThrough] public static bool operator !=(Size lhs, Size rhs); /// Indicates whether this instance and a specified object are equal. /// The object to compare with the current instance. /// /// if and this instance are the same type and represent the same value; otherwise, . [DebuggerStepThrough] public override bool Equals(object? obj); /// /// Returns true if this size is equal to the specified . /// public bool Equals(Size other); /// Returns the hash code for this instance. /// A 32-bit signed integer that is the hash code for this instance. [DebuggerStepThrough] public override int GetHashCode(); /// /// Returns the minimum of two sizes, using the smaller width and height from each. /// public static Size Min(Size lhs, Size rhs); /// /// Returns the maximum of two sizes, using the larger width and height from each. /// public static Size Max(Size lhs, Size rhs); } /// /// Represents a 2D vector with X and Y components, commonly used for geometric operations, /// layout math, and movement in 2D space. /// public struct Vector { /// The horizontal component of the vector. public nfloat X; /// The vertical component of the vector. public nfloat Y; /// /// Initializes a new instance of the struct /// with the specified X and Y components. /// /// The horizontal component of the vector. /// The vertical component of the vector. [DebuggerStepThrough] public Vector(nfloat x, nfloat y); /// A zero vector (0, 0). public static readonly Vector Zero; /// A unit vector (1, 1). public static readonly Vector One; /// A unit vector pointing left (-1, 0). public static readonly Vector Left; /// A unit vector pointing up (0, -1). public static readonly Vector Up; /// A unit vector pointing right (1, 0). public static readonly Vector Right; /// A unit vector pointing down (0, 1). public static readonly Vector Down; /// /// Returns a normalized (unit length) version of this vector. /// public Vector Normalized { get; } /// /// Returns the vector rotated 90° counter-clockwise (CCW). /// public Vector PerpendicularCCW { get; } /// /// Returns the vector rotated 90° clockwise (CW). /// public Vector PerpendicularCW { get; } /// /// Returns the magnitude (length) of the vector. /// public nfloat Magnitude { get; } /// /// Returns the magnitude (length) of the vector. /// public nfloat Length { get; } /// /// Returns the squared magnitude (length squared) of the vector. /// This avoids the square root computation used in . /// public nfloat MagnitudeSquared { 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. /// /// /// The angle in radians between this vector and the X-axis. /// public nfloat ArcAngle { get; } /// /// Rotates the vector counterclockwise by the given angle (in degrees). /// public Vector Rotate(nfloat degrees); /// /// Returns the dot product of two vectors. /// [DebuggerStepThrough] public static nfloat Dot(Vector lhs, Vector rhs); /// /// Projects onto . /// [DebuggerStepThrough] public static Vector Project(Vector lhs, Vector rhs); /// /// Returns the 2D cross product (scalar) of two vectors. /// [DebuggerStepThrough] public static nfloat Cross(Vector lhs, Vector rhs); /// /// Returns a new vector with its magnitude limited to the specified maximum. /// [DebuggerStepThrough] public Vector Clamp(nfloat max); /// /// Returns the clockwise angle (in radians) from the upward direction (0, 1) to the given vector. /// [DebuggerStepThrough] public static nfloat Angle(Vector v); /// /// Returns a unit vector rotated clockwise from the upward direction (0, 1) by the given angle (in radians). /// [DebuggerStepThrough] public static Vector Angle(nfloat radians); /// /// Returns the signed angle (in radians) from to , clockwise from upward. /// [DebuggerStepThrough] public static nfloat Angle(Vector lhs, Vector rhs); /// /// Linearly interpolates between two vectors by . /// [DebuggerStepThrough] public static Vector Lerp(Vector start, Vector end, nfloat step); /// /// Implicitly converts a to a . /// [DebuggerStepThrough] public static implicit operator Vector(Point point); /// /// Multiplies a vector by a scalar. /// [DebuggerStepThrough] public static Vector operator *(Vector v, nfloat f); /// /// Divides a vector by a scalar. /// [DebuggerStepThrough] public static Vector operator /(Vector v, nfloat f); /// /// Multiplies a scalar by a vector. /// [DebuggerStepThrough] public static Vector operator *(nfloat f, Vector v); /// /// Adds two vectors. /// [DebuggerStepThrough] public static Vector operator +(Vector lhs, Vector rhs); /// /// Subtracts one vector from another. /// [DebuggerStepThrough] public static Vector operator -(Vector lhs, Vector rhs); /// /// Implicitly converts a tuple to a . /// [DebuggerStepThrough] public static implicit operator Vector(ValueTuple tuple); /// /// Returns true if the two vectors have equal components. /// [DebuggerStepThrough] public static bool operator ==(Vector lhs, Vector rhs); /// /// Returns true if any component of the two vectors is different. /// [DebuggerStepThrough] public static bool operator !=(Vector lhs, Vector rhs); /// Indicates whether this instance and a specified object are equal. /// The object to compare with the current instance. /// /// if and this instance are the same type and represent the same value; otherwise, . public override bool Equals(object? obj); /// /// Returns true if this vector is equal to another vector. /// public bool Equals(Vector other); /// Returns the hash code for this instance. /// A 32-bit signed integer that is the hash code for this instance. public override int GetHashCode(); /// Returns the fully qualified type name of this instance. /// The fully qualified type name. public override string ToString(); } } namespace Xui.Core.Math2D { using System.Runtime.CompilerServices; /// /// Represents a point in 2D space, defined by its and coordinates. /// public struct Point { /// The X-coordinate of the point. public nfloat X; /// The Y-coordinate of the point. public nfloat Y; /// A point at the origin (0, 0). public static readonly Point Zero; /// /// A point at (1, 1), useful for normalized coordinates or vector math. /// public static readonly Point One; /// /// Initializes a new point with the specified coordinates. /// [DebuggerStepThrough] public Point(nfloat x, nfloat y); /// /// Linearly interpolates between two points by . /// /// The start point. /// The end point. /// A value from 0 to 1 indicating the interpolation position. [DebuggerStepThrough] public static Point Lerp(Point start, Point end, nfloat step); /// /// Returns the Euclidean distance between two points. /// [DebuggerStepThrough] public static nfloat Distance(Point a, Point b); /// /// Returns the squared Euclidean distance between two points (no square root). /// Useful for performance comparisons or ordering by proximity. /// [DebuggerStepThrough] public static nfloat SquaredDistance(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. /// [DebuggerStepThrough] public static nfloat TaxicabDistance(Point a, Point b); /// /// Returns the vector difference from one point to another. /// [DebuggerStepThrough] public static Vector operator -(Point lhs, Point rhs); /// /// Offsets a point by a vector. /// [DebuggerStepThrough] public static Point operator +(Point lhs, Vector rhs); /// /// Subtracts a vector from a point, offsetting it in the opposite direction. /// [DebuggerStepThrough] public static Point operator -(Point lhs, Vector rhs); /// /// Converts a tuple to a point. /// [DebuggerStepThrough] public static implicit operator Point(ValueTuple tuple); /// /// Explicitly converts a vector to a point (drops directional semantics). /// [DebuggerStepThrough] public static explicit operator Point(Vector vector); /// /// Determines whether two points have equal coordinates. /// [DebuggerStepThrough] public static bool operator ==(Point lhs, Point rhs); /// /// Determines whether two points differ in any coordinate. /// [DebuggerStepThrough] public static bool operator !=(Point lhs, Point rhs); /// /// Apply an uniform scale to a point. /// [DebuggerStepThrough] public static Point operator *(Point v, nfloat f); /// Returns the fully qualified type name of this instance. /// The fully qualified type name. public override string ToString(); /// Indicates whether this instance and a specified object are equal. /// The object to compare with the current instance. /// /// if and this instance are the same type and represent the same value; otherwise, . public override bool Equals(object? obj); /// /// Returns true if this point has the same coordinates as another. /// public bool Equals(Point other); /// Returns the hash code for this instance. /// A 32-bit signed integer that is the hash code for this instance. public override int GetHashCode(); } } namespace Xui.Core.Math2D { using Xui.Core.Set; /// /// Represents a rectangle in 2D space, defined by its origin (, ) /// and its dimensions (, ). /// /// /// Unlike , which represents edge thicknesses around a box, /// defines a positioned, sized area used for layout and rendering. /// public struct Rect : INonEnumerableSet, IEquatable { /// The X-coordinate of the rectangle’s top-left corner. public nfloat X; /// The Y-coordinate of the rectangle’s top-left corner. public nfloat Y; /// The width of the rectangle. public nfloat Width; /// The height of the rectangle. public nfloat Height; /// /// Creates a new from position and size. /// [DebuggerStepThrough] public Rect(nfloat x, nfloat y, nfloat width, nfloat height); /// /// Creates a new from a top-left point and a size. /// [DebuggerStepThrough] public Rect(Point topLeft, Size size); /// /// Creates a new from a top-left vector and a size. /// [DebuggerStepThrough] public Rect(Vector topLeft, Size size); /// Returns the top-left point of the rectangle. [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Point TopLeft { get; } /// Returns the top-center point of the rectangle. [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Point TopCenter { get; } /// Returns the top-right point of the rectangle. [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Point TopRight { get; } /// Returns the bottom-right point of the rectangle. [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Point BottomRight { get; } /// Returns the bottom-left point of the rectangle. [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Point BottomLeft { get; } /// Returns the X-coordinate of the left edge. [DebuggerBrowsable(DebuggerBrowsableState.Never)] public nfloat Left { get; } /// Returns the Y-coordinate of the top edge. [DebuggerBrowsable(DebuggerBrowsableState.Never)] public nfloat Top { get; } /// Returns the X-coordinate of the right edge. [DebuggerBrowsable(DebuggerBrowsableState.Never)] public nfloat Right { get; } /// Returns the Y-coordinate of the bottom edge. [DebuggerBrowsable(DebuggerBrowsableState.Never)] public nfloat Bottom { get; } /// /// Returns the center point of the rectangle. /// public Point Center { get; } /// /// Gets or sets the size of the rectangle. /// [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Size Size { get; set; } /// /// Returns a new rectangle that is inset by the same amount on all four sides. /// [DebuggerStepThrough] public Rect Inset(nfloat inset); /// /// Returns true if the specified lies within this rectangle. /// [DebuggerStepThrough] public bool Contains(Point point); /// Returns whether this rectangle overlaps or touches . [DebuggerStepThrough] public bool Intersects(Rect other); /// /// Returns a rectangle expanded horizontally and vertically by the specified amounts. /// [DebuggerStepThrough] public Rect Expand(nfloat h, nfloat v); /// /// Returns a rectangle expanded uniformly in all directions. /// [DebuggerStepThrough] public Rect Expand(nfloat expand); /// /// Implicit conversion from a 4-tuple to a rectangle. /// [DebuggerStepThrough] public static implicit operator Rect(ValueTuple tuple); /// /// Returns a rectangle expanded outward by a . /// [DebuggerStepThrough] public static Rect operator +(Rect rect, Frame frame); /// /// Returns a rectangle inset inward by a . /// [DebuggerStepThrough] public static Rect operator -(Rect rect, Frame frame); /// /// Returns true if two rectangles are equal in position and size. /// [DebuggerStepThrough] public static bool operator ==(Rect lhs, Rect rhs); /// /// Returns true if any of the rectangle fields are different. /// [DebuggerStepThrough] public static bool operator !=(Rect lhs, Rect rhs); /// Indicates whether this instance and a specified object are equal. /// The object to compare with the current instance. /// /// if and this instance are the same type and represent the same value; otherwise, . public override bool Equals(object? obj); /// /// Returns true if this rectangle is equal to another rectangle in position and size. /// public bool Equals(Rect other); /// Returns the hash code for this instance. /// A 32-bit signed integer that is the hash code for this instance. public override int GetHashCode(); /// Returns the fully qualified type name of this instance. /// The fully qualified type name. [DebuggerStepThrough] public override string ToString(); } }