Xui.Core.Canvas
Assembly: Xui.Core · C# declarations · Assembly overview
Types
class AssetUristruct Colorclass Colorsstruct CornerRadiusenum FillRulereadonly struct Fontclass FontCache<T>readonly struct FontFaceDescriptorreadonly struct FontMetricsclass FontMetricsCachereadonly struct FontResourceclass FontSourcereadonly struct FontStretchstruct FontStylereadonly struct FontWeightstruct GradientStopinterface ICompositionContextinterface IContextinterface IFilterContextinterface IFontSourceinterface IGlyphPathBuilderinterface IImageinterface IImageDrawingContextinterface IMeasureContextinterface IPathBuilderinterface IPathClippinginterface IPathDrawinginterface IPathDrawingContextinterface IPenContextinterface IRectDrawingContextinterface IStateContextinterface ISymbolContextinterface ITextDrawingContextinterface ITextMeasureContextinterface ITransformContextref struct ImagePatternenum LineCapenum LineJoinreadonly struct LineMetricsref struct LinearGradientenum PaintStyleclass Path2Denum PatternRepeatref struct RadialGradientclass RoundedRectenum TextAlignenum TextBaselinereadonly struct TextMetricsclass TextMetricsCacheenum Winding
class AssetUri
Parses the portable URI form used for application-packaged image assets. asset://icons/logo.png identifies the logical asset icons/logo.png; each runtime resolves it from its application package.
public static class AssetUri
{
public static bool TryGetRelativePath(string uri, out string relativePath);
}
bool AssetUri.TryGetRelativePath(string uri, out string relativePath)
public static bool TryGetRelativePath(string uri, out string relativePath);
Gets an asset's logical relative path. Returns false when uri is not a valid asset:// URI.
struct Color
Represents a color using red, green, blue, and alpha components, all normalized to the range [0, 1].
public struct Color : IEquatable<Color>
{
public readonly bool Equals(Color other);
public override readonly bool Equals(object? obj);
public override readonly int GetHashCode();
public nfloat Red;
public nfloat Green;
public nfloat Blue;
public nfloat Alpha;
public Color(nfloat red, nfloat green, nfloat blue, nfloat alpha);
public Color(byte red, byte green, byte blue, byte alpha);
public Color(uint rgba);
public readonly bool IsTransparent { get; }
public static implicit operator Color(uint rgbaHex);
}
Color.Color(byte red, byte green, byte blue, byte alpha)
public Color(byte red, byte green, byte blue, byte alpha);
Initializes a new Xui.Core.Canvas.Color from byte components in the range [0, 255], which are normalized to [0, 1].
red— Red component [0, 255]green— Green component [0, 255]blue— Blue component [0, 255]alpha— Alpha component [0, 255]
Color.Color(NFloat red, NFloat green, NFloat blue, NFloat alpha)
public Color(nfloat red, nfloat green, nfloat blue, nfloat alpha);
Initializes a new Xui.Core.Canvas.Color with the specified red, green, blue, and alpha components.
red— Red component, normalized [0, 1]green— Green component, normalized [0, 1]blue— Blue component, normalized [0, 1]alpha— Alpha component, normalized [0, 1]
Color.Color(uint rgba)
public Color(uint rgba);
Initializes a new Xui.Core.Canvas.Color from a packed 32-bit RGBA value. The value format is 0xRRGGBBAA, where each component is 8 bits.
rgba— Packed RGBA value in 0xRRGGBBAA format.
NFloat Color.Alpha
public nfloat Alpha;
Alpha (opacity) component of the color, in the range [0, 1].
NFloat Color.Blue
public nfloat Blue;
Blue component of the color, in the range [0, 1].
readonly bool Color.Equals(object? obj)
public override readonly 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.
readonly bool Color.Equals(Color other)
public readonly bool Equals(Color other);
Indicates whether the current object is equal to another object of the same type.
other— An object to compare with this object.
Returns: true if the current object is equal to the other parameter; otherwise, false.
readonly int Color.GetHashCode()
public override readonly int GetHashCode();
Returns the hash code for this instance.
Returns: A 32-bit signed integer that is the hash code for this instance.
NFloat Color.Green
public nfloat Green;
Green component of the color, in the range [0, 1].
readonly bool Color.IsTransparent
public readonly bool IsTransparent { get; }
Returns true if the color is fully transparent (Alpha = 0).
NFloat Color.Red
public nfloat Red;
Red component of the color, in the range [0, 1].
Color.implicit operator Color(uint rgbaHex)
public static implicit operator Color(uint rgbaHex);
Implicitly converts a 32-bit RGBA value (0xRRGGBBAA) to a Xui.Core.Canvas.Color.
rgbaHex— Packed RGBA hex value.
class Colors
Provides web standard named color constants in 32-bit RGBA format (0xRRGGBBAA). These match the named colors from the CSS color specification: https://developer.mozilla.org/en-US/docs/Web/CSS/named-color
public static class Colors
{
public const uint Transparent = 0x00000000;
public const uint Black = 0x000000FF;
public const uint White = 0xFFFFFFFF;
public const uint Red = 0xFF0000FF;
public const uint Lime = 0x00FF00FF;
public const uint Blue = 0x0000FFFF;
public const uint Yellow = 0xFFFF00FF;
public const uint Fuchsia = 0xFF00FFFF;
public const uint Aqua = 0x00FFFFFF;
public const uint Silver = 0xC0C0C0FF;
public const uint Gray = 0x808080FF;
public const uint Maroon = 0x800000FF;
public const uint Purple = 0x800080FF;
public const uint Green = 0x008000FF;
public const uint Olive = 0x808000FF;
public const uint Navy = 0x000080FF;
public const uint Teal = 0x008080FF;
public const uint AliceBlue = 0xf0f8ffFF;
public const uint AntiqueWhite = 0xfaebd7FF;
public const uint Aquamarine = 0x7fffd4FF;
public const uint Azure = 0xf0ffffFF;
public const uint Beige = 0xf5f5dcFF;
public const uint Bisque = 0xffe4c4FF;
public const uint BlanchedAlmond = 0xffebcdFF;
public const uint BlueViolet = 0x8a2be2FF;
public const uint Brown = 0xa52a2aFF;
public const uint BurlyWood = 0xdeb887FF;
public const uint CadetBlue = 0x5f9ea0FF;
public const uint ChartReuse = 0x7fff00FF;
public const uint Chocolate = 0xd2691eFF;
public const uint Coral = 0xff7f50FF;
public const uint CornflowerBlue = 0x6495edFF;
public const uint CornSilk = 0xfff8dcFF;
public const uint Crimson = 0xdc143cFF;
public const uint Cyan = 0x00ffffFF;
public const uint DarkBlue = 0x00008bFF;
public const uint DarkCyan = 0x008b8bFF;
public const uint DarkGoldenRod = 0xb8860bFF;
public const uint DarkGray = 0xa9a9a9FF;
public const uint DarkGreen = 0x006400FF;
public const uint DarkGrey = 0xa9a9a9FF;
public const uint DarkKhaki = 0xbdb76bFF;
public const uint DarkMagenta = 0x8b008bFF;
public const uint DarkOliveGreen = 0x556b2fFF;
public const uint DarkOrange = 0xff8c00FF;
public const uint DarkOrchid = 0x9932ccFF;
public const uint DarkRed = 0x8b0000FF;
public const uint DarkSalmon = 0xe9967aFF;
public const uint DarkSeaGreen = 0x8fbc8fFF;
public const uint DarkSlateBlue = 0x483d8bFF;
public const uint DarkSlateGray = 0x2f4f4fFF;
public const uint DarkSlateGrey = 0x2f4f4fFF;
public const uint DarkTurquoise = 0x00ced1FF;
public const uint DarkViolet = 0x9400d3FF;
public const uint DeepPink = 0xff1493FF;
public const uint DeepSkyBlue = 0x00bfffFF;
public const uint DimGray = 0x696969FF;
public const uint DimGrey = 0x696969FF;
public const uint DodgerBlue = 0x1e90ffFF;
public const uint FireBrick = 0xb22222FF;
public const uint FloralWhite = 0xfffaf0FF;
public const uint ForestGreen = 0x228b22FF;
public const uint Gainsboro = 0xdcdcdcFF;
public const uint GhostWhite = 0xf8f8ffFF;
public const uint Gold = 0xffd700FF;
public const uint GoldenRod = 0xdaa520FF;
public const uint GreenYellow = 0xadff2fFF;
public const uint Grey = 0x808080FF;
public const uint Honeydew = 0xf0fff0FF;
public const uint HotPink = 0xff69b4FF;
public const uint IndianRed = 0xcd5c5cFF;
public const uint Indigo = 0x4b0082FF;
public const uint Ivory = 0xfffff0FF;
public const uint Khaki = 0xf0e68cFF;
public const uint Lavender = 0xe6e6faFF;
public const uint LavenderBlush = 0xfff0f5FF;
public const uint LawnGreen = 0x7cfc00FF;
public const uint LemonChiffon = 0xfffacdFF;
public const uint LightBlue = 0xadd8e6FF;
public const uint LightCoral = 0xf08080FF;
public const uint LightCyan = 0xe0ffffFF;
public const uint LightGoldenRodYellow = 0xfafad2FF;
public const uint LightGray = 0xd3d3d3FF;
public const uint LightGreen = 0x90ee90FF;
public const uint LightGrey = 0xd3d3d3FF;
public const uint LightPink = 0xffb6c1FF;
public const uint LightSalmon = 0xffa07aFF;
public const uint LightSeaGreen = 0x20b2aaFF;
public const uint LightSkyBlue = 0x87cefaFF;
public const uint LightSlateGray = 0x778899FF;
public const uint LightSlateGrey = 0x778899FF;
public const uint LightSteelBlue = 0xb0c4deFF;
public const uint LightYellow = 0xffffe0FF;
public const uint LimeGreen = 0x32cd32FF;
public const uint Linen = 0xfaf0e6FF;
public const uint Magenta = 0xff00ffFF;
public const uint MediumAquamarine = 0x66cdaaFF;
public const uint MediumBlue = 0x0000cdFF;
public const uint MediumOrchid = 0xba55d3FF;
public const uint MediumPurple = 0x9370dbFF;
public const uint MediumSeaGreen = 0x3cb371FF;
public const uint MediumSlateBlue = 0x7b68eeFF;
public const uint MediumSpringGreen = 0x00fa9aFF;
public const uint MediumTurquoise = 0x48d1ccFF;
public const uint MediumVioletRed = 0xc71585FF;
public const uint MidnightBlue = 0x191970FF;
public const uint MintCream = 0xf5fffaFF;
public const uint MistyRose = 0xffe4e1FF;
public const uint Moccasin = 0xffe4b5FF;
public const uint NavajoWhite = 0xffdeadFF;
public const uint OldLace = 0xfdf5e6FF;
public const uint OliveDrab = 0x6b8e23FF;
public const uint Orange = 0xffa500FF;
public const uint OrangeRed = 0xff4500FF;
public const uint Orchid = 0xda70d6FF;
public const uint PaleGoldenRod = 0xeee8aaFF;
public const uint PaleGreen = 0x98fb98FF;
public const uint PaleTurquoise = 0xafeeeeFF;
public const uint PaleVioletRed = 0xdb7093FF;
public const uint PapayaWhip = 0xffefd5FF;
public const uint PeachPuff = 0xffdab9FF;
public const uint Peru = 0xcd853fFF;
public const uint Pink = 0xffc0cbFF;
public const uint Plum = 0xdda0ddFF;
public const uint PowderBlue = 0xb0e0e6FF;
public const uint RebeccaPurple = 0x663399FF;
public const uint RosyBrown = 0xbc8f8fFF;
public const uint RoyalBlue = 0x4169e1FF;
public const uint SaddleBrown = 0x8b4513FF;
public const uint Salmon = 0xfa8072FF;
public const uint SandyBrown = 0xf4a460FF;
public const uint SeaGreen = 0x2e8b57FF;
public const uint Seashell = 0xfff5eeFF;
public const uint Sienna = 0xa0522dFF;
public const uint SkyBlue = 0x87ceebFF;
public const uint SlateBlue = 0x6a5acdFF;
public const uint SlateGray = 0x708090FF;
public const uint SlateGrey = 0x708090FF;
public const uint Snow = 0xfffafaFF;
public const uint SpringGreen = 0x00ff7fFF;
public const uint SteelBlue = 0x4682b4FF;
public const uint Tan = 0xd2b48cFF;
public const uint Thistle = 0xd8bfd8FF;
public const uint Tomato = 0xff6347FF;
public const uint Turquoise = 0x40e0d0FF;
public const uint Violet = 0xee82eeFF;
public const uint Wheat = 0xf5deb3FF;
public const uint WhiteSmoke = 0xf5f5f5FF;
public const uint YellowGreen = 0x9acd32FF;
}
uint Colors.AliceBlue
public const uint AliceBlue = 0xf0f8ffFF;
uint Colors.AntiqueWhite
public const uint AntiqueWhite = 0xfaebd7FF;
uint Colors.Aqua
public const uint Aqua = 0x00FFFFFF;
uint Colors.Aquamarine
public const uint Aquamarine = 0x7fffd4FF;
uint Colors.Azure
public const uint Azure = 0xf0ffffFF;
uint Colors.Beige
public const uint Beige = 0xf5f5dcFF;
uint Colors.Bisque
public const uint Bisque = 0xffe4c4FF;
uint Colors.Black
public const uint Black = 0x000000FF;
uint Colors.BlanchedAlmond
public const uint BlanchedAlmond = 0xffebcdFF;
uint Colors.Blue
public const uint Blue = 0x0000FFFF;
uint Colors.BlueViolet
public const uint BlueViolet = 0x8a2be2FF;
uint Colors.Brown
public const uint Brown = 0xa52a2aFF;
uint Colors.BurlyWood
public const uint BurlyWood = 0xdeb887FF;
uint Colors.CadetBlue
public const uint CadetBlue = 0x5f9ea0FF;
uint Colors.ChartReuse
public const uint ChartReuse = 0x7fff00FF;
uint Colors.Chocolate
public const uint Chocolate = 0xd2691eFF;
uint Colors.Coral
public const uint Coral = 0xff7f50FF;
uint Colors.CornSilk
public const uint CornSilk = 0xfff8dcFF;
uint Colors.CornflowerBlue
public const uint CornflowerBlue = 0x6495edFF;
uint Colors.Crimson
public const uint Crimson = 0xdc143cFF;
uint Colors.Cyan
public const uint Cyan = 0x00ffffFF;
uint Colors.DarkBlue
public const uint DarkBlue = 0x00008bFF;
uint Colors.DarkCyan
public const uint DarkCyan = 0x008b8bFF;
uint Colors.DarkGoldenRod
public const uint DarkGoldenRod = 0xb8860bFF;
uint Colors.DarkGray
public const uint DarkGray = 0xa9a9a9FF;
uint Colors.DarkGreen
public const uint DarkGreen = 0x006400FF;
uint Colors.DarkGrey
public const uint DarkGrey = 0xa9a9a9FF;
uint Colors.DarkKhaki
public const uint DarkKhaki = 0xbdb76bFF;
uint Colors.DarkMagenta
public const uint DarkMagenta = 0x8b008bFF;
uint Colors.DarkOliveGreen
public const uint DarkOliveGreen = 0x556b2fFF;
uint Colors.DarkOrange
public const uint DarkOrange = 0xff8c00FF;
uint Colors.DarkOrchid
public const uint DarkOrchid = 0x9932ccFF;
uint Colors.DarkRed
public const uint DarkRed = 0x8b0000FF;
uint Colors.DarkSalmon
public const uint DarkSalmon = 0xe9967aFF;
uint Colors.DarkSeaGreen
public const uint DarkSeaGreen = 0x8fbc8fFF;
uint Colors.DarkSlateBlue
public const uint DarkSlateBlue = 0x483d8bFF;
uint Colors.DarkSlateGray
public const uint DarkSlateGray = 0x2f4f4fFF;
uint Colors.DarkSlateGrey
public const uint DarkSlateGrey = 0x2f4f4fFF;
uint Colors.DarkTurquoise
public const uint DarkTurquoise = 0x00ced1FF;
uint Colors.DarkViolet
public const uint DarkViolet = 0x9400d3FF;
uint Colors.DeepPink
public const uint DeepPink = 0xff1493FF;
uint Colors.DeepSkyBlue
public const uint DeepSkyBlue = 0x00bfffFF;
uint Colors.DimGray
public const uint DimGray = 0x696969FF;
uint Colors.DimGrey
public const uint DimGrey = 0x696969FF;
uint Colors.DodgerBlue
public const uint DodgerBlue = 0x1e90ffFF;
uint Colors.FireBrick
public const uint FireBrick = 0xb22222FF;
uint Colors.FloralWhite
public const uint FloralWhite = 0xfffaf0FF;
uint Colors.ForestGreen
public const uint ForestGreen = 0x228b22FF;
uint Colors.Fuchsia
public const uint Fuchsia = 0xFF00FFFF;
uint Colors.Gainsboro
public const uint Gainsboro = 0xdcdcdcFF;
uint Colors.GhostWhite
public const uint GhostWhite = 0xf8f8ffFF;
uint Colors.Gold
public const uint Gold = 0xffd700FF;
uint Colors.GoldenRod
public const uint GoldenRod = 0xdaa520FF;
uint Colors.Gray
public const uint Gray = 0x808080FF;
uint Colors.Green
public const uint Green = 0x008000FF;
uint Colors.GreenYellow
public const uint GreenYellow = 0xadff2fFF;
uint Colors.Grey
public const uint Grey = 0x808080FF;
uint Colors.Honeydew
public const uint Honeydew = 0xf0fff0FF;
uint Colors.HotPink
public const uint HotPink = 0xff69b4FF;
uint Colors.IndianRed
public const uint IndianRed = 0xcd5c5cFF;
uint Colors.Indigo
public const uint Indigo = 0x4b0082FF;
uint Colors.Ivory
public const uint Ivory = 0xfffff0FF;
uint Colors.Khaki
public const uint Khaki = 0xf0e68cFF;
uint Colors.Lavender
public const uint Lavender = 0xe6e6faFF;
uint Colors.LavenderBlush
public const uint LavenderBlush = 0xfff0f5FF;
uint Colors.LawnGreen
public const uint LawnGreen = 0x7cfc00FF;
uint Colors.LemonChiffon
public const uint LemonChiffon = 0xfffacdFF;
uint Colors.LightBlue
public const uint LightBlue = 0xadd8e6FF;
uint Colors.LightCoral
public const uint LightCoral = 0xf08080FF;
uint Colors.LightCyan
public const uint LightCyan = 0xe0ffffFF;
uint Colors.LightGoldenRodYellow
public const uint LightGoldenRodYellow = 0xfafad2FF;
uint Colors.LightGray
public const uint LightGray = 0xd3d3d3FF;
uint Colors.LightGreen
public const uint LightGreen = 0x90ee90FF;
uint Colors.LightGrey
public const uint LightGrey = 0xd3d3d3FF;
uint Colors.LightPink
public const uint LightPink = 0xffb6c1FF;
uint Colors.LightSalmon
public const uint LightSalmon = 0xffa07aFF;
uint Colors.LightSeaGreen
public const uint LightSeaGreen = 0x20b2aaFF;
uint Colors.LightSkyBlue
public const uint LightSkyBlue = 0x87cefaFF;
uint Colors.LightSlateGray
public const uint LightSlateGray = 0x778899FF;
uint Colors.LightSlateGrey
public const uint LightSlateGrey = 0x778899FF;
uint Colors.LightSteelBlue
public const uint LightSteelBlue = 0xb0c4deFF;
uint Colors.LightYellow
public const uint LightYellow = 0xffffe0FF;
uint Colors.Lime
public const uint Lime = 0x00FF00FF;
uint Colors.LimeGreen
public const uint LimeGreen = 0x32cd32FF;
uint Colors.Linen
public const uint Linen = 0xfaf0e6FF;
uint Colors.Magenta
public const uint Magenta = 0xff00ffFF;
uint Colors.Maroon
public const uint Maroon = 0x800000FF;
uint Colors.MediumAquamarine
public const uint MediumAquamarine = 0x66cdaaFF;
uint Colors.MediumBlue
public const uint MediumBlue = 0x0000cdFF;
uint Colors.MediumOrchid
public const uint MediumOrchid = 0xba55d3FF;
uint Colors.MediumPurple
public const uint MediumPurple = 0x9370dbFF;
uint Colors.MediumSeaGreen
public const uint MediumSeaGreen = 0x3cb371FF;
uint Colors.MediumSlateBlue
public const uint MediumSlateBlue = 0x7b68eeFF;
uint Colors.MediumSpringGreen
public const uint MediumSpringGreen = 0x00fa9aFF;
uint Colors.MediumTurquoise
public const uint MediumTurquoise = 0x48d1ccFF;
uint Colors.MediumVioletRed
public const uint MediumVioletRed = 0xc71585FF;
uint Colors.MidnightBlue
public const uint MidnightBlue = 0x191970FF;
uint Colors.MintCream
public const uint MintCream = 0xf5fffaFF;
uint Colors.MistyRose
public const uint MistyRose = 0xffe4e1FF;
uint Colors.Moccasin
public const uint Moccasin = 0xffe4b5FF;
uint Colors.NavajoWhite
public const uint NavajoWhite = 0xffdeadFF;
uint Colors.Navy
public const uint Navy = 0x000080FF;
uint Colors.OldLace
public const uint OldLace = 0xfdf5e6FF;
uint Colors.Olive
public const uint Olive = 0x808000FF;
uint Colors.OliveDrab
public const uint OliveDrab = 0x6b8e23FF;
uint Colors.Orange
public const uint Orange = 0xffa500FF;
uint Colors.OrangeRed
public const uint OrangeRed = 0xff4500FF;
uint Colors.Orchid
public const uint Orchid = 0xda70d6FF;
uint Colors.PaleGoldenRod
public const uint PaleGoldenRod = 0xeee8aaFF;
uint Colors.PaleGreen
public const uint PaleGreen = 0x98fb98FF;
uint Colors.PaleTurquoise
public const uint PaleTurquoise = 0xafeeeeFF;
uint Colors.PaleVioletRed
public const uint PaleVioletRed = 0xdb7093FF;
uint Colors.PapayaWhip
public const uint PapayaWhip = 0xffefd5FF;
uint Colors.PeachPuff
public const uint PeachPuff = 0xffdab9FF;
uint Colors.Peru
public const uint Peru = 0xcd853fFF;
uint Colors.Pink
public const uint Pink = 0xffc0cbFF;
uint Colors.Plum
public const uint Plum = 0xdda0ddFF;
uint Colors.PowderBlue
public const uint PowderBlue = 0xb0e0e6FF;
uint Colors.Purple
public const uint Purple = 0x800080FF;
uint Colors.RebeccaPurple
public const uint RebeccaPurple = 0x663399FF;
uint Colors.Red
public const uint Red = 0xFF0000FF;
uint Colors.RosyBrown
public const uint RosyBrown = 0xbc8f8fFF;
uint Colors.RoyalBlue
public const uint RoyalBlue = 0x4169e1FF;
uint Colors.SaddleBrown
public const uint SaddleBrown = 0x8b4513FF;
uint Colors.Salmon
public const uint Salmon = 0xfa8072FF;
uint Colors.SandyBrown
public const uint SandyBrown = 0xf4a460FF;
uint Colors.SeaGreen
public const uint SeaGreen = 0x2e8b57FF;
uint Colors.Seashell
public const uint Seashell = 0xfff5eeFF;
uint Colors.Sienna
public const uint Sienna = 0xa0522dFF;
uint Colors.Silver
public const uint Silver = 0xC0C0C0FF;
uint Colors.SkyBlue
public const uint SkyBlue = 0x87ceebFF;
uint Colors.SlateBlue
public const uint SlateBlue = 0x6a5acdFF;
uint Colors.SlateGray
public const uint SlateGray = 0x708090FF;
uint Colors.SlateGrey
public const uint SlateGrey = 0x708090FF;
uint Colors.Snow
public const uint Snow = 0xfffafaFF;
uint Colors.SpringGreen
public const uint SpringGreen = 0x00ff7fFF;
uint Colors.SteelBlue
public const uint SteelBlue = 0x4682b4FF;
uint Colors.Tan
public const uint Tan = 0xd2b48cFF;
uint Colors.Teal
public const uint Teal = 0x008080FF;
uint Colors.Thistle
public const uint Thistle = 0xd8bfd8FF;
uint Colors.Tomato
public const uint Tomato = 0xff6347FF;
uint Colors.Transparent
public const uint Transparent = 0x00000000;
uint Colors.Turquoise
public const uint Turquoise = 0x40e0d0FF;
uint Colors.Violet
public const uint Violet = 0xee82eeFF;
uint Colors.Wheat
public const uint Wheat = 0xf5deb3FF;
uint Colors.White
public const uint White = 0xFFFFFFFF;
uint Colors.WhiteSmoke
public const uint WhiteSmoke = 0xf5f5f5FF;
uint Colors.Yellow
public const uint Yellow = 0xFFFF00FF;
uint Colors.YellowGreen
public const uint YellowGreen = 0x9acd32FF;
struct CornerRadius
Represents the radius of each corner of a rectangle, allowing for uniform or non-uniform rounding.
public struct CornerRadius
{
public static readonly CornerRadius Zero;
public nfloat TopLeft;
public nfloat TopRight;
public nfloat BottomRight;
public nfloat BottomLeft;
public bool IsUniform { get; }
public readonly bool IsZero { get; }
[DebuggerStepThrough]
public CornerRadius(nfloat radius);
[DebuggerStepThrough]
public CornerRadius(nfloat topLeft, nfloat topRight, nfloat bottomRight, nfloat bottomLeft);
public static implicit operator CornerRadius(nfloat radius);
public static implicit operator CornerRadius(int radius);
public static implicit operator CornerRadius(Tuple<nfloat, nfloat, nfloat, nfloat> radii);
[DebuggerStepThrough]
public static CornerRadius operator +(CornerRadius lhs, CornerRadius rhs);
[DebuggerStepThrough]
public static CornerRadius operator -(CornerRadius lhs, CornerRadius rhs);
[DebuggerStepThrough]
public static CornerRadius Min(CornerRadius a, CornerRadius b);
[DebuggerStepThrough]
public static CornerRadius Max(CornerRadius a, CornerRadius b);
[DebuggerStepThrough]
public static implicit operator CornerRadius((nfloat horizontal, nfloat vertical) radii);
[DebuggerStepThrough]
public static implicit operator CornerRadius((nfloat topLeft, nfloat topRight, nfloat bottomRight, nfloat bottomLeft) radii);
}
CornerRadius.CornerRadius(NFloat radius)
[DebuggerStepThrough]
public CornerRadius(nfloat radius);
Initializes a Xui.Core.Canvas.CornerRadius with the same radius applied to all four corners.
radius— The uniform radius for all corners.
CornerRadius.CornerRadius(NFloat topLeft, NFloat topRight, NFloat bottomRight, NFloat bottomLeft)
[DebuggerStepThrough]
public CornerRadius(nfloat topLeft, nfloat topRight, nfloat bottomRight, nfloat bottomLeft);
Initializes a Xui.Core.Canvas.CornerRadius with individual values for each corner.
topLeft— Radius of the top-left corner.topRight— Radius of the top-right corner.bottomRight— Radius of the bottom-right corner.bottomLeft— Radius of the bottom-left corner.
NFloat CornerRadius.BottomLeft
public nfloat BottomLeft;
Radius of the bottom-left corner.
NFloat CornerRadius.BottomRight
public nfloat BottomRight;
Radius of the bottom-right corner.
bool CornerRadius.IsUniform
public bool IsUniform { get; }
Returns true if all corners have the same radius value.
readonly bool CornerRadius.IsZero
public readonly bool IsZero { get; }
Returns true if all corner radii are zero.
CornerRadius CornerRadius.Max(CornerRadius a, CornerRadius b)
[DebuggerStepThrough]
public static CornerRadius Max(CornerRadius a, CornerRadius b);
Returns a Xui.Core.Canvas.CornerRadius where each corner is the maximum of the corresponding corners of the two inputs.
a— FirstXui.Core.Canvas.CornerRadius.b— SecondXui.Core.Canvas.CornerRadius.
Returns: A new Xui.Core.Canvas.CornerRadius taking the maximum value at each corner.
CornerRadius CornerRadius.Min(CornerRadius a, CornerRadius b)
[DebuggerStepThrough]
public static CornerRadius Min(CornerRadius a, CornerRadius b);
Returns a Xui.Core.Canvas.CornerRadius where each corner is the minimum of the corresponding corners of the two inputs.
a— FirstXui.Core.Canvas.CornerRadius.b— SecondXui.Core.Canvas.CornerRadius.
Returns: A new Xui.Core.Canvas.CornerRadius taking the minimum value at each corner.
NFloat CornerRadius.TopLeft
public nfloat TopLeft;
Radius of the top-left corner.
NFloat CornerRadius.TopRight
public nfloat TopRight;
Radius of the top-right corner.
CornerRadius CornerRadius.Zero
public static readonly CornerRadius Zero;
A Xui.Core.Canvas.CornerRadius where all corners have a radius of zero.
CornerRadius CornerRadius.operator +(CornerRadius lhs, CornerRadius rhs)
[DebuggerStepThrough]
public static CornerRadius operator +(CornerRadius lhs, CornerRadius rhs);
Adds two Xui.Core.Canvas.CornerRadius values component-wise.
lhs— The firstXui.Core.Canvas.CornerRadius.rhs— The secondXui.Core.Canvas.CornerRadius.
Returns: A new Xui.Core.Canvas.CornerRadius where each corner is the sum of the corresponding corners.
CornerRadius.implicit operator CornerRadius(int radius)
public static implicit operator CornerRadius(int radius);
Implicitly converts a single integer radius value to a uniform Xui.Core.Canvas.CornerRadius.
radius— The uniform corner radius.
CornerRadius.implicit operator CornerRadius(NFloat radius)
public static implicit operator CornerRadius(nfloat radius);
Implicitly converts a single radius value to a uniform Xui.Core.Canvas.CornerRadius.
radius— The uniform corner radius.
CornerRadius.implicit operator CornerRadius(Tuple<NFloat, NFloat, NFloat, NFloat> radii)
public static implicit operator CornerRadius(Tuple<nfloat, nfloat, nfloat, nfloat> radii);
Implicitly converts a 4-tuple of radius values to a Xui.Core.Canvas.CornerRadius.
radii— Tuple representing (TopLeft, TopRight, BottomRight, BottomLeft).
CornerRadius.implicit operator CornerRadius((NFloat topLeft, NFloat topRight, NFloat bottomRight, NFloat bottomLeft) radii)
[DebuggerStepThrough]
public static implicit operator CornerRadius((nfloat topLeft, nfloat topRight, nfloat bottomRight, nfloat bottomLeft) radii);
Implicitly converts a tuple (topLeft, topRight, bottomRight, bottomLeft) into a Xui.Core.Canvas.CornerRadius.
radii— Tuple of four radii representing each corner individually.
CornerRadius.implicit operator CornerRadius((NFloat horizontal, NFloat vertical) radii)
[DebuggerStepThrough]
public static implicit operator CornerRadius((nfloat horizontal, nfloat vertical) radii);
Implicitly converts a tuple (horizontal, vertical) into a Xui.Core.Canvas.CornerRadius, where TopLeft and BottomRight use horizontal, and TopRight and BottomLeft use vertical radius.
radii— Tuple of two radii (horizontal, vertical).
CornerRadius CornerRadius.operator -(CornerRadius lhs, CornerRadius rhs)
[DebuggerStepThrough]
public static CornerRadius operator -(CornerRadius lhs, CornerRadius rhs);
Subtracts one Xui.Core.Canvas.CornerRadius from another component-wise.
lhs— The firstXui.Core.Canvas.CornerRadius.rhs— The secondXui.Core.Canvas.CornerRadiusto subtract.
Returns: A new Xui.Core.Canvas.CornerRadius where each corner is the difference of the corresponding corners.
enum FillRule
Specifies the algorithm used to determine the "insideness" of a point in a path, controlling how filled shapes are rendered.
public enum FillRule
{
NonZero,
EvenOdd
}
FillRule.EvenOdd
EvenOdd
Uses the even-odd rule. A point is inside the path if a ray drawn from it to infinity crosses the path segments an odd number of times.
FillRule.NonZero
NonZero
Uses the non-zero winding rule. A point is inside the path if the sum of path segment windings around it is non-zero. This is the default rule.
readonly struct Font
Immutable description of one font face used for canvas text measurement and rendering.
Xui currently selects one named family. Font fallback and per-run font selection are not supported by this value and must bypass font-metric caches when introduced in the future.
public partial struct Font
{
public static readonly FontWeight Thin;
public static readonly FontWeight ExtraLight;
public static readonly FontWeight Light;
public static readonly FontWeight Medium;
public static readonly FontWeight SemiBold;
public static readonly FontWeight Bold;
public static readonly FontWeight ExtraBold;
public static readonly FontWeight Black;
public static readonly FontStretch UltraCondensed;
public static readonly FontStretch ExtraCondensed;
public static readonly FontStretch Condensed;
public static readonly FontStretch SemiCondensed;
public static readonly FontStretch SemiExpanded;
public static readonly FontStretch Expanded;
public static readonly FontStretch ExtraExpanded;
public static readonly FontStretch UltraExpanded;
public static readonly FontStyle Italic;
public static readonly FontStyle Oblique;
}
public partial struct Font
{
public static implicit operator Font(float size);
public static implicit operator Font((float size, FontWeight weight) tuple);
public static implicit operator Font((float size, FontStyle style) tuple);
public static implicit operator Font((float size, FontWeight weight, FontStyle style) tuple);
public static implicit operator Font((float size, FontWeight weight, FontStretch stretch) tuple);
public static implicit operator Font((float size, FontStyle style, FontStretch stretch) tuple);
public static implicit operator Font((float size, FontWeight weight, FontStyle style, FontStretch stretch) tuple);
public static implicit operator Font((float size, float lineHeight) tuple);
public static implicit operator Font((float size, FontWeight weight, float lineHeight) tuple);
public static implicit operator Font((float size, FontStyle style, float lineHeight) tuple);
public static implicit operator Font((float size, FontWeight weight, FontStyle style, float lineHeight) tuple);
public static implicit operator Font((float size, FontWeight weight, FontStretch stretch, float lineHeight) tuple);
public static implicit operator Font((float size, FontStyle style, FontStretch stretch, float lineHeight) tuple);
public static implicit operator Font((float size, FontWeight weight, FontStyle style, FontStretch stretch, float lineHeight) tuple);
}
public readonly partial struct Font : IEquatable<Font>
{
public Font();
public Font(nfloat fontSize, string fontFamily, FontWeight? fontWeight = null, FontStyle? fontStyle = null, FontStretch? fontStretch = null, nfloat? lineHeight = null);
public string FontFamily { get; init; }
public nfloat FontSize { get; init; }
public FontStyle FontStyle { get; init; }
public FontWeight FontWeight { get; init; }
public FontStretch FontStretch { get; init; }
public nfloat LineHeight { get; init; }
public bool Equals(Font other);
public override bool Equals(object? obj);
public override int GetHashCode();
public static bool operator ==(Font left, Font right);
public static bool operator !=(Font left, Font right);
}
Font.Font()
public Font();
Initializes the default Inter text font.
Font.Font(NFloat fontSize, string fontFamily, FontWeight? fontWeight = null, FontStyle? fontStyle = null, FontStretch? fontStretch = null, NFloat? lineHeight = null)
public Font(nfloat fontSize, string fontFamily, FontWeight? fontWeight = null, FontStyle? fontStyle = null, FontStretch? fontStretch = null, nfloat? lineHeight = null);
Initializes a font face.
FontWeight Font.Black
public static readonly FontWeight Black;
FontWeight Font.Bold
public static readonly FontWeight Bold;
FontStretch Font.Condensed
public static readonly FontStretch Condensed;
bool Font.Equals(object? obj)
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.
bool Font.Equals(Font other)
public bool Equals(Font other);
Indicates whether the current object is equal to another object of the same type.
other— An object to compare with this object.
Returns: true if the current object is equal to the other parameter; otherwise, false.
FontStretch Font.Expanded
public static readonly FontStretch Expanded;
FontWeight Font.ExtraBold
public static readonly FontWeight ExtraBold;
FontStretch Font.ExtraCondensed
public static readonly FontStretch ExtraCondensed;
FontStretch Font.ExtraExpanded
public static readonly FontStretch ExtraExpanded;
FontWeight Font.ExtraLight
public static readonly FontWeight ExtraLight;
string Font.FontFamily
public string FontFamily { get; init; }
The one selected font family name.
NFloat Font.FontSize
public nfloat FontSize { get; init; }
The font size in user-space units.
FontStretch Font.FontStretch
public FontStretch FontStretch { get; init; }
The font stretch.
FontStyle Font.FontStyle
public FontStyle FontStyle { get; init; }
The font style.
FontWeight Font.FontWeight
public FontWeight FontWeight { get; init; }
The numeric font weight.
int Font.GetHashCode()
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.
FontStyle Font.Italic
public static readonly FontStyle Italic;
FontWeight Font.Light
public static readonly FontWeight Light;
NFloat Font.LineHeight
public nfloat LineHeight { get; init; }
The requested line height. Layout will own line-spacing semantics.
FontWeight Font.Medium
public static readonly FontWeight Medium;
FontStyle Font.Oblique
public static readonly FontStyle Oblique;
FontWeight Font.SemiBold
public static readonly FontWeight SemiBold;
FontStretch Font.SemiCondensed
public static readonly FontStretch SemiCondensed;
FontStretch Font.SemiExpanded
public static readonly FontStretch SemiExpanded;
FontWeight Font.Thin
public static readonly FontWeight Thin;
FontStretch Font.UltraCondensed
public static readonly FontStretch UltraCondensed;
FontStretch Font.UltraExpanded
public static readonly FontStretch UltraExpanded;
bool Font.operator ==(Font left, Font right)
public static bool operator ==(Font left, Font right);
Returns whether two font descriptions are equal.
Font.implicit operator Font(float size)
public static implicit operator Font(float size);
Implicitly creates a Xui.Core.Canvas.Font from a font size. Uses normal weight, normal style, normal stretch, and line height = 1.2× size.
size— The font size in user-space units (e.g., pixels).
Font.implicit operator Font((float size, float lineHeight) tuple)
public static implicit operator Font((float size, float lineHeight) tuple);
Creates a Xui.Core.Canvas.Font from size and line height.
Font.implicit operator Font((float size, FontStyle style, float lineHeight) tuple)
public static implicit operator Font((float size, FontStyle style, float lineHeight) tuple);
Creates a Xui.Core.Canvas.Font from size, style, and line height.
Font.implicit operator Font((float size, FontStyle style, FontStretch stretch, float lineHeight) tuple)
public static implicit operator Font((float size, FontStyle style, FontStretch stretch, float lineHeight) tuple);
Creates a Xui.Core.Canvas.Font from size, style, stretch, and line height.
Font.implicit operator Font((float size, FontStyle style, FontStretch stretch) tuple)
public static implicit operator Font((float size, FontStyle style, FontStretch stretch) tuple);
Implicitly creates a Xui.Core.Canvas.Font from size, style, and stretch. Uses normal weight and line height = 1.2× size.
tuple— The font size, style, and stretch percentage.
Font.implicit operator Font((float size, FontStyle style) tuple)
public static implicit operator Font((float size, FontStyle style) tuple);
Implicitly creates a Xui.Core.Canvas.Font from a font size and style. Uses normal weight, normal stretch, and line height = 1.2× size.
tuple— The font size and font style.
Font.implicit operator Font((float size, FontWeight weight, float lineHeight) tuple)
public static implicit operator Font((float size, FontWeight weight, float lineHeight) tuple);
Creates a Xui.Core.Canvas.Font from size, weight, and line height.
Font.implicit operator Font((float size, FontWeight weight, FontStretch stretch, float lineHeight) tuple)
public static implicit operator Font((float size, FontWeight weight, FontStretch stretch, float lineHeight) tuple);
Creates a Xui.Core.Canvas.Font from size, weight, stretch, and line height.
Font.implicit operator Font((float size, FontWeight weight, FontStretch stretch) tuple)
public static implicit operator Font((float size, FontWeight weight, FontStretch stretch) tuple);
Implicitly creates a Xui.Core.Canvas.Font from size, weight, and stretch. Uses normal style and line height = 1.2× size.
tuple— The font size, weight, and stretch percentage.
Font.implicit operator Font((float size, FontWeight weight, FontStyle style, float lineHeight) tuple)
public static implicit operator Font((float size, FontWeight weight, FontStyle style, float lineHeight) tuple);
Creates a Xui.Core.Canvas.Font from size, weight, style, and line height.
Font.implicit operator Font((float size, FontWeight weight, FontStyle style, FontStretch stretch, float lineHeight) tuple)
public static implicit operator Font((float size, FontWeight weight, FontStyle style, FontStretch stretch, float lineHeight) tuple);
Creates a Xui.Core.Canvas.Font from size, weight, style, stretch, and line height.
Font.implicit operator Font((float size, FontWeight weight, FontStyle style, FontStretch stretch) tuple)
public static implicit operator Font((float size, FontWeight weight, FontStyle style, FontStretch stretch) tuple);
Implicitly creates a Xui.Core.Canvas.Font from size, weight, style, and stretch. Uses line height = 1.2× size.
tuple— The font size, weight, style, and stretch percentage.
Font.implicit operator Font((float size, FontWeight weight, FontStyle style) tuple)
public static implicit operator Font((float size, FontWeight weight, FontStyle style) tuple);
Implicitly creates a Xui.Core.Canvas.Font from size, weight, and style. Uses normal stretch and line height = 1.2× size.
tuple— The font size, weight, and style.
Font.implicit operator Font((float size, FontWeight weight) tuple)
public static implicit operator Font((float size, FontWeight weight) tuple);
Implicitly creates a Xui.Core.Canvas.Font from a font size and weight. Uses normal style, normal stretch, and line height = 1.2× size.
tuple— The font size and font weight.
bool Font.operator !=(Font left, Font right)
public static bool operator !=(Font left, Font right);
Returns whether two font descriptions differ.
class FontCache<T>
Fixed-capacity, allocation-free-after-construction LRU cache keyed by Xui.Core.Canvas.Font.
T— The cached value associated with a resolved font.
public class FontCache<T>
{
public const int DefaultCapacity = 64;
public FontCache(int capacity = DefaultCapacity);
public int EntryCapacity { get; }
public bool TryGet(in Font font, out T value);
public void Set(in Font font, T value);
public void Clear();
protected virtual void OnEvicted(T value);
}
FontCache<T>.FontCache(int capacity = 64)
public FontCache(int capacity = DefaultCapacity);
Initializes a cache with the requested number of entries.
void FontCache<T>.Clear()
public void Clear();
Clears every retained entry.
int FontCache<T>.DefaultCapacity
public const int DefaultCapacity = 64;
The standard number of font entries retained by a context cache.
int FontCache<T>.EntryCapacity
public int EntryCapacity { get; }
Gets the number of retained font entries.
void FontCache<T>.OnEvicted(T value)
protected virtual void OnEvicted(T value);
Releases a value when its entry is replaced, evicted, or cleared.
void FontCache<T>.Set(in Font font, T value)
public void Set(in Font font, T value);
Adds or refreshes the value for font.
bool FontCache<T>.TryGet(in Font font, out T value)
public bool TryGet(in Font font, out T value);
Gets the cached value for font when available.
readonly struct FontFaceDescriptor
Describes one concrete font face made available by an application.
public readonly struct FontFaceDescriptor
{
public string Family { get; }
public FontWeight Weight { get; }
public FontStyle Style { get; }
public FontStretch Stretch { get; }
public FontFaceDescriptor(string family, FontWeight weight, FontStyle style, FontStretch stretch);
public bool Matches(in Font font);
}
FontFaceDescriptor.FontFaceDescriptor(string family, FontWeight weight, FontStyle style, FontStretch stretch)
public FontFaceDescriptor(string family, FontWeight weight, FontStyle style, FontStretch stretch);
Initializes a concrete face descriptor.
string FontFaceDescriptor.Family
public string Family { get; }
The case-insensitive family name.
bool FontFaceDescriptor.Matches(in Font font)
public bool Matches(in Font font);
Returns whether this exact face satisfies font.
FontStretch FontFaceDescriptor.Stretch
public FontStretch Stretch { get; }
The width/stretch percentage.
FontStyle FontFaceDescriptor.Style
public FontStyle Style { get; }
The italic or oblique style.
FontWeight FontFaceDescriptor.Weight
public FontWeight Weight { get; }
The numeric weight.
readonly struct FontMetrics
Represents font-defined metrics used for vertical alignment and em box sizing. These values are constant for a given font and size.
public readonly struct FontMetrics
{
public readonly nfloat FontBoundingBoxAscent;
public readonly nfloat FontBoundingBoxDescent;
public readonly nfloat EmHeightAscent;
public readonly nfloat EmHeightDescent;
public readonly nfloat AlphabeticBaseline;
public readonly nfloat HangingBaseline;
public readonly nfloat IdeographicBaseline;
public nfloat Height { get; }
public FontMetrics(nfloat fontAscent, nfloat fontDescent, nfloat emAscent, nfloat emDescent, nfloat alphabeticBaseline, nfloat hangingBaseline, nfloat ideographicBaseline);
}
FontMetrics.FontMetrics(NFloat fontAscent, NFloat fontDescent, NFloat emAscent, NFloat emDescent, NFloat alphabeticBaseline, NFloat hangingBaseline, NFloat ideographicBaseline)
public FontMetrics(nfloat fontAscent, nfloat fontDescent, nfloat emAscent, nfloat emDescent, nfloat alphabeticBaseline, nfloat hangingBaseline, nfloat ideographicBaseline);
Initializes a new Xui.Core.Canvas.FontMetrics instance.
fontAscent— Maximum vertical extent above the baseline from the font’s bounding box.fontDescent— Maximum vertical extent below the baseline from the font’s bounding box.emAscent— Ascent to the top of the em square.emDescent— Descent to the bottom of the em square.alphabeticBaseline— Position of the alphabetic baseline (typically 0).hangingBaseline— Position of the hanging baseline for scripts that use it.ideographicBaseline— Position of the ideographic baseline for CJK layout.
NFloat FontMetrics.AlphabeticBaseline
public readonly nfloat AlphabeticBaseline;
Position of the alphabetic baseline (typically 0, used for alignment).
NFloat FontMetrics.EmHeightAscent
public readonly nfloat EmHeightAscent;
Height from baseline to top of the em square. Recommended for app layout.
NFloat FontMetrics.EmHeightDescent
public readonly nfloat EmHeightDescent;
Height from baseline to bottom of the em square. Recommended for app layout.
NFloat FontMetrics.FontBoundingBoxAscent
public readonly nfloat FontBoundingBoxAscent;
Maximum ascent defined by the font (not necessarily used glyphs).
NFloat FontMetrics.FontBoundingBoxDescent
public readonly nfloat FontBoundingBoxDescent;
Maximum descent defined by the font.
NFloat FontMetrics.HangingBaseline
public readonly nfloat HangingBaseline;
Vertical position of the hanging baseline (used in scripts like Devanagari), relative to the alphabetic baseline. Negative values are above it.
NFloat FontMetrics.Height
public nfloat Height { get; }
Total height of the font bounding box.
NFloat FontMetrics.IdeographicBaseline
public readonly nfloat IdeographicBaseline;
Vertical position of the ideographic baseline (used in CJK layout), relative to the alphabetic baseline. Positive values are below it.
class FontMetricsCache
Fixed-capacity, allocation-free-after-construction LRU cache of font-wide metrics. One instance belongs to a drawing or measurement context because native font resolution is surface-specific.
public sealed class FontMetricsCache : FontCache<FontMetrics>
{
public const int Capacity = DefaultCapacity;
public FontMetricsCache();
}
FontMetricsCache.FontMetricsCache()
public FontMetricsCache();
Initializes the standard 64-entry metrics cache.
int FontMetricsCache.Capacity
public const int Capacity = DefaultCapacity;
Maximum number of distinct font descriptions retained by this cache.
readonly struct FontResource
Identifies one font resource without loading its data.
public readonly struct FontResource
{
public FontFaceDescriptor Face { get; }
public Uri Uri { get; }
public FontResource(FontFaceDescriptor face, Uri uri);
}
FontResource.FontResource(FontFaceDescriptor face, Uri uri)
public FontResource(FontFaceDescriptor face, Uri uri);
Initializes a font resource.
FontFaceDescriptor FontResource.Face
public FontFaceDescriptor Face { get; }
The concrete face represented by this resource.
Uri FontResource.Uri
public Uri Uri { get; }
The source location understood by the supplying source.
class FontSource
URI-backed implementation of Xui.Core.Canvas.IFontSource.
public sealed class FontSource : IFontSource
{
public FontSource(IEnumerable<FontResource> resources, Func<Uri, ReadOnlyMemory<byte>> loader);
public IEnumerable<FontResource> Resources { get; }
public bool TryGet(in Font font, out FontResource resource);
public ReadOnlyMemory<byte> Load(in FontResource resource);
public static ReadOnlyMemory<byte> LoadEmbedded(Uri uri);
}
FontSource.FontSource(IEnumerable<FontResource> resources, Func<Uri, ReadOnlyMemory<byte>> loader)
public FontSource(IEnumerable<FontResource> resources, Func<Uri, ReadOnlyMemory<byte>> loader);
Initializes a URI-backed source with its resource declarations and loader.
ReadOnlyMemory<byte> FontSource.Load(in FontResource resource)
public ReadOnlyMemory<byte> Load(in FontResource resource);
Loads a resource's bytes when a consumer needs them.
ReadOnlyMemory<byte> FontSource.LoadEmbedded(Uri uri)
public static ReadOnlyMemory<byte> LoadEmbedded(Uri uri);
Loads a resource addressed as embedded://Assembly/Path/File.ttf.
IEnumerable<FontResource> FontSource.Resources
public IEnumerable<FontResource> Resources { get; }
Gets all declared resources without loading their data.
bool FontSource.TryGet(in Font font, out FontResource resource)
public bool TryGet(in Font font, out FontResource resource);
Finds the exact application-provided face for a request.
readonly struct FontStretch
Represents the stretch or width percentage of a font, relative to its normal width (100%).
Values less than 100 represent condensed fonts; values greater than 100 are expanded. Font stretch supports comparison operators for ordering and matching.
public readonly struct FontStretch : IComparable<FontStretch>, IEquatable<FontStretch>
{
public readonly nfloat Value;
public FontStretch(nfloat value);
public static implicit operator nfloat(FontStretch stretch);
public static implicit operator FontStretch(nfloat value);
public static implicit operator FontStretch(float value);
public static implicit operator FontStretch(int value);
public static bool operator ==(FontStretch a, FontStretch b);
public static bool operator !=(FontStretch a, FontStretch b);
public static bool operator <(FontStretch a, FontStretch b);
public static bool operator <=(FontStretch a, FontStretch b);
public static bool operator>(FontStretch a, FontStretch b);
public static bool operator >=(FontStretch a, FontStretch b);
public int CompareTo(FontStretch other);
public bool Equals(FontStretch other);
public override bool Equals(object? obj);
public override int GetHashCode();
public static readonly FontStretch UltraCondensed;
public static readonly FontStretch ExtraCondensed;
public static readonly FontStretch Condensed;
public static readonly FontStretch SemiCondensed;
public static readonly FontStretch Normal;
public static readonly FontStretch SemiExpanded;
public static readonly FontStretch Expanded;
public static readonly FontStretch ExtraExpanded;
public static readonly FontStretch UltraExpanded;
}
FontStretch.FontStretch(NFloat value)
public FontStretch(nfloat value);
Initializes a new Xui.Core.Canvas.FontStretch with the specified numeric value.
value— The numeric width percentage (e.g., 100 = normal).
int FontStretch.CompareTo(FontStretch other)
public int CompareTo(FontStretch other);
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
other— An object to compare with this instance.
Returns: A value that indicates the relative order of the objects being compared. The return value has these meanings:
- Less than zero — This instance precedes
otherin the sort order. - Zero — This instance occurs in the same position in the sort order as
other. - Greater than zero — This instance follows
otherin the sort order.
FontStretch FontStretch.Condensed
public static readonly FontStretch Condensed;
Font stretch 75% – Condensed. Common for space-constrained text.
bool FontStretch.Equals(object? obj)
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.
bool FontStretch.Equals(FontStretch other)
public bool Equals(FontStretch other);
Indicates whether the current object is equal to another object of the same type.
other— An object to compare with this object.
Returns: true if the current object is equal to the other parameter; otherwise, false.
FontStretch FontStretch.Expanded
public static readonly FontStretch Expanded;
Font stretch 125% – Expanded. Wider glyph appearance.
FontStretch FontStretch.ExtraCondensed
public static readonly FontStretch ExtraCondensed;
Font stretch 62.5% – Extra Condensed. Narrower than Condensed.
FontStretch FontStretch.ExtraExpanded
public static readonly FontStretch ExtraExpanded;
Font stretch 150% – Extra Expanded. Significantly wider.
int FontStretch.GetHashCode()
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.
FontStretch FontStretch.Normal
public static readonly FontStretch Normal;
Font stretch 100% – Normal. Default glyph width.
FontStretch FontStretch.SemiCondensed
public static readonly FontStretch SemiCondensed;
Font stretch 87.5% – Semi Condensed. Slightly narrower than normal.
FontStretch FontStretch.SemiExpanded
public static readonly FontStretch SemiExpanded;
Font stretch 112.5% – Semi Expanded. Slightly wider than normal.
FontStretch FontStretch.UltraCondensed
public static readonly FontStretch UltraCondensed;
Font stretch 50% – Ultra Condensed. Very narrow glyph width.
FontStretch FontStretch.UltraExpanded
public static readonly FontStretch UltraExpanded;
Font stretch 200% – Ultra Expanded. Very wide glyphs.
NFloat FontStretch.Value
public readonly nfloat Value;
The numeric percentage value of the font stretch.
bool FontStretch.operator ==(FontStretch a, FontStretch b)
public static bool operator ==(FontStretch a, FontStretch b);
Returns true if two stretch values are equal.
bool FontStretch.operator >(FontStretch a, FontStretch b)
public static bool operator>(FontStretch a, FontStretch b);
Returns true if the left stretch is greater than the right.
bool FontStretch.operator >=(FontStretch a, FontStretch b)
public static bool operator >=(FontStretch a, FontStretch b);
Returns true if the left stretch is greater than or equal to the right.
FontStretch.implicit operator FontStretch(int value)
public static implicit operator FontStretch(int value);
Implicitly converts an System.Int32 to Xui.Core.Canvas.FontStretch.
FontStretch.implicit operator FontStretch(NFloat value)
public static implicit operator FontStretch(nfloat value);
Implicitly converts a System.Runtime.InteropServices.NFloat to Xui.Core.Canvas.FontStretch.
FontStretch.implicit operator FontStretch(float value)
public static implicit operator FontStretch(float value);
Implicitly converts a System.Single to Xui.Core.Canvas.FontStretch.
FontStretch.implicit operator NFloat(FontStretch stretch)
public static implicit operator nfloat(FontStretch stretch);
Implicitly converts a Xui.Core.Canvas.FontStretch to System.Runtime.InteropServices.NFloat.
bool FontStretch.operator !=(FontStretch a, FontStretch b)
public static bool operator !=(FontStretch a, FontStretch b);
Returns true if two stretch values are not equal.
bool FontStretch.operator <(FontStretch a, FontStretch b)
public static bool operator <(FontStretch a, FontStretch b);
Returns true if the left stretch is less than the right.
bool FontStretch.operator <=(FontStretch a, FontStretch b)
public static bool operator <=(FontStretch a, FontStretch b);
Returns true if the left stretch is less than or equal to the right.
struct FontStyle
Represents a web-like font style, supporting normal, italic, and oblique variations. Global CSS styles like inherit, unset, and initial are not supported. Reference: https://developer.mozilla.org/en-US/docs/Web/CSS/font-style
public struct FontStyle
{
[DebuggerStepThrough]
public FontStyle(bool italic, bool oblique, nfloat obliqueAngle);
public bool IsItalic { get; }
public bool IsOblique { get; }
public nfloat ObliqueAngle { get; }
public static FontStyle Normal { get; }
public static FontStyle Italic { get; }
public static FontStyle Oblique { get; }
[DebuggerStepThrough]
public static FontStyle CustomOblique(nfloat obliqueAngle);
}
FontStyle.FontStyle(bool italic, bool oblique, NFloat obliqueAngle)
[DebuggerStepThrough]
public FontStyle(bool italic, bool oblique, nfloat obliqueAngle);
Initializes a new Xui.Core.Canvas.FontStyle with explicit flags for italic or oblique styling.
italic— Whether the font is italic.oblique— Whether the font is oblique (slanted).obliqueAngle— Angle for oblique style, in degrees.
FontStyle FontStyle.CustomOblique(NFloat obliqueAngle)
[DebuggerStepThrough]
public static FontStyle CustomOblique(nfloat obliqueAngle);
Creates a custom oblique font style with a specific slant angle.
obliqueAngle— The angle of the slant, in degrees. Should be between -90 and 90.
Returns: A Xui.Core.Canvas.FontStyle representing the custom oblique angle.
bool FontStyle.IsItalic
public bool IsItalic { get; }
Gets a value indicating whether the font style is italic.
bool FontStyle.IsOblique
public bool IsOblique { get; }
Gets a value indicating whether the font style is oblique (slanted).
FontStyle FontStyle.Italic
public static FontStyle Italic { get; }
Italic font style.
FontStyle FontStyle.Normal
public static FontStyle Normal { get; }
Normal (upright) font style.
FontStyle FontStyle.Oblique
public static FontStyle Oblique { get; }
Oblique font style using the default slant angle (14°).
NFloat FontStyle.ObliqueAngle
public nfloat ObliqueAngle { get; }
Gets the oblique slant angle, in degrees. Only meaningful if Xui.Core.Canvas.FontStyle.IsOblique is true. Range is typically from -90° to 90°.
readonly struct FontWeight
Represents the numeric weight of a font, corresponding to CSS font weights (100–900).
Font weights are numeric and allow comparison using operators like <, >=, etc.
public readonly struct FontWeight : IComparable<FontWeight>, IEquatable<FontWeight>
{
public readonly nfloat Value;
public FontWeight(nfloat value);
public static implicit operator nfloat(FontWeight weight);
public static implicit operator uint (FontWeight weight);
public static implicit operator FontWeight(nfloat value);
public static implicit operator FontWeight(float value);
public static implicit operator FontWeight(int value);
public static bool operator ==(FontWeight a, FontWeight b);
public static bool operator !=(FontWeight a, FontWeight b);
public static bool operator <(FontWeight a, FontWeight b);
public static bool operator <=(FontWeight a, FontWeight b);
public static bool operator>(FontWeight a, FontWeight b);
public static bool operator >=(FontWeight a, FontWeight b);
public int CompareTo(FontWeight other);
public bool Equals(FontWeight other);
public override bool Equals(object? obj);
public override int GetHashCode();
public static readonly FontWeight Thin;
public static readonly FontWeight ExtraLight;
public static readonly FontWeight Light;
public static readonly FontWeight Normal;
public static readonly FontWeight Medium;
public static readonly FontWeight SemiBold;
public static readonly FontWeight Bold;
public static readonly FontWeight ExtraBold;
public static readonly FontWeight Black;
}
FontWeight.FontWeight(NFloat value)
public FontWeight(nfloat value);
Creates a new Xui.Core.Canvas.FontWeight with the specified numeric value.
value— The numeric font weight value.
FontWeight FontWeight.Black
public static readonly FontWeight Black;
Font weight 900 – Black. The heaviest available weight.
FontWeight FontWeight.Bold
public static readonly FontWeight Bold;
Font weight 700 – Bold. Common for emphasis and headings.
int FontWeight.CompareTo(FontWeight other)
public int CompareTo(FontWeight other);
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
other— An object to compare with this instance.
Returns: A value that indicates the relative order of the objects being compared. The return value has these meanings:
- Less than zero — This instance precedes
otherin the sort order. - Zero — This instance occurs in the same position in the sort order as
other. - Greater than zero — This instance follows
otherin the sort order.
bool FontWeight.Equals(object? obj)
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.
bool FontWeight.Equals(FontWeight other)
public bool Equals(FontWeight other);
Indicates whether the current object is equal to another object of the same type.
other— An object to compare with this object.
Returns: true if the current object is equal to the other parameter; otherwise, false.
FontWeight FontWeight.ExtraBold
public static readonly FontWeight ExtraBold;
Font weight 800 – Extra Bold. Heavier than Bold.
FontWeight FontWeight.ExtraLight
public static readonly FontWeight ExtraLight;
Font weight 200 – Extra Light. Slightly heavier than Thin.
int FontWeight.GetHashCode()
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.
FontWeight FontWeight.Light
public static readonly FontWeight Light;
Font weight 300 – Light. Common for minimalist design.
FontWeight FontWeight.Medium
public static readonly FontWeight Medium;
Font weight 500 – Medium. Slightly heavier than normal.
FontWeight FontWeight.Normal
public static readonly FontWeight Normal;
Font weight 400 – Normal. Standard weight for body text.
FontWeight FontWeight.SemiBold
public static readonly FontWeight SemiBold;
Font weight 600 – Semi Bold. Between medium and bold.
FontWeight FontWeight.Thin
public static readonly FontWeight Thin;
Font weight 100 – Thin. The lightest possible weight.
NFloat FontWeight.Value
public readonly nfloat Value;
The numeric value of the font weight.
bool FontWeight.operator ==(FontWeight a, FontWeight b)
public static bool operator ==(FontWeight a, FontWeight b);
Returns true if two font weights are equal.
bool FontWeight.operator >(FontWeight a, FontWeight b)
public static bool operator>(FontWeight a, FontWeight b);
Returns true if the left font weight is greater than the right.
bool FontWeight.operator >=(FontWeight a, FontWeight b)
public static bool operator >=(FontWeight a, FontWeight b);
Returns true if the left font weight is greater than or equal to the right.
FontWeight.implicit operator FontWeight(int value)
public static implicit operator FontWeight(int value);
Implicitly converts an System.Int32 to Xui.Core.Canvas.FontWeight.
FontWeight.implicit operator FontWeight(NFloat value)
public static implicit operator FontWeight(nfloat value);
Implicitly converts a System.Runtime.InteropServices.NFloat to Xui.Core.Canvas.FontWeight.
FontWeight.implicit operator FontWeight(float value)
public static implicit operator FontWeight(float value);
Implicitly converts a System.Single to Xui.Core.Canvas.FontWeight.
FontWeight.implicit operator NFloat(FontWeight weight)
public static implicit operator nfloat(FontWeight weight);
Implicitly converts a Xui.Core.Canvas.FontWeight to System.Runtime.InteropServices.NFloat.
FontWeight.implicit operator uint(FontWeight weight)
public static implicit operator uint (FontWeight weight);
Implicitly converts a Xui.Core.Canvas.FontWeight to System.Runtime.InteropServices.NFloat.
bool FontWeight.operator !=(FontWeight a, FontWeight b)
public static bool operator !=(FontWeight a, FontWeight b);
Returns true if two font weights are not equal.
bool FontWeight.operator <(FontWeight a, FontWeight b)
public static bool operator <(FontWeight a, FontWeight b);
Returns true if the left font weight is less than the right.
bool FontWeight.operator <=(FontWeight a, FontWeight b)
public static bool operator <=(FontWeight a, FontWeight b);
Returns true if the left font weight is less than or equal to the right.
struct GradientStop
Represents a single color stop in a gradient, defined by an offset and a color. Used for both linear and radial gradients.
public struct GradientStop
{
public nfloat Offset;
public Color Color;
public GradientStop(nfloat offset, Color color);
public GradientStop(nfloat offset, uint color);
public static implicit operator GradientStop((nfloat Offset, Color Color) pair);
public static implicit operator GradientStop((nfloat Offset, uint Color) pair);
}
GradientStop.GradientStop(NFloat offset, uint color)
public GradientStop(nfloat offset, uint color);
Initializes a new Xui.Core.Canvas.GradientStop with a specified offset and packed RGBA color.
offset— Position of the color stop, usually from 0 to 1.color— Color in packed 0xRRGGBBAA format.
GradientStop.GradientStop(NFloat offset, Color color)
public GradientStop(nfloat offset, Color color);
Initializes a new Xui.Core.Canvas.GradientStop with a specified offset and color.
offset— Position of the color stop, usually from 0 to 1.color— Color at the given offset.
Color GradientStop.Color
public Color Color;
The color at the specified offset.
NFloat GradientStop.Offset
public nfloat Offset;
The position of the stop within the gradient, typically in the range [0, 1].
GradientStop.implicit operator GradientStop((NFloat Offset, uint Color) pair)
public static implicit operator GradientStop((nfloat Offset, uint Color) pair);
Implicitly converts a tuple of System.Runtime.InteropServices.NFloat and uint (0xRRGGBBAA) to a Xui.Core.Canvas.GradientStop.
pair— A tuple containing offset and packed RGBA color.
GradientStop.implicit operator GradientStop((NFloat Offset, Color Color) pair)
public static implicit operator GradientStop((nfloat Offset, Color Color) pair);
Implicitly converts a tuple of System.Runtime.InteropServices.NFloat and Xui.Core.Canvas.GradientStop.Color to a Xui.Core.Canvas.GradientStop.
pair— A tuple containing offset and color.
interface ICompositionContext
Declares explicit groups in the drawing order of a canvas.
public interface ICompositionContext
{
CompositionGroup Group(scoped in GroupOptions options);
bool GpuSurface(scoped in GroupOptions options);
bool GpuSurface(scoped in GroupOptions options, out GpuSurfaceFailure failure);
static void ValidateGpuSurface(scoped in GroupOptions options);
void EndGroup();
}
void ICompositionContext.EndGroup()
void EndGroup();
Closes the innermost group. Called by Xui.Core.Canvas.Composition.Graphics.CompositionGroup.Dispose; prefer disposing the returned scope over calling this directly.
bool ICompositionContext.GpuSurface(scoped in GroupOptions options)
bool GpuSurface(scoped in GroupOptions options);
Declares a native GPU leaf in drawing order. Key must be a stable class implementing IGpuSurfaceContent; Bounds is required. Rendering is deferred until native placement, and requested when HasUpdates is true or the retained surface needs fresh content. Available from a Window render context as well as a View render context.
Returns: True when native presentation is supported here; false requests an explicit application fallback (for example an offscreen image for SVG export). A false return does not change composition state. Arbitrary inherited canvas clips are unsupported; use group bounds clipping. Native GPU content does not inherit canvas paint/filter.
Example
A Window can declare the surface directly from its RenderEventRef.Context:
context.GpuSurface(new GroupOptions
{
Key = cube, // cube implements IGpuSurfaceContent
Bounds = displayArea,
HasUpdates = cubeChanged
});
Check the returned bool and render a portable fallback when false.
bool ICompositionContext.GpuSurface(scoped in GroupOptions options, out GpuSurfaceFailure failure)
bool GpuSurface(scoped in GroupOptions options, out GpuSurfaceFailure failure);
Attempts native GPU presentation and reports why it could not be accepted. Use Xui.Core.Canvas.Composition.GPU.GpuSurfaceFailure.NotSupported to display an unavailable message; Xui.Core.Canvas.Composition.GPU.GpuSurfaceFailure.PortableFallbackRequired permits an explicit export or offscreen fallback. Invalid options and rendering/shader errors still throw.
Older contexts preserve their existing portable-fallback behavior.
CompositionGroup ICompositionContext.Group(scoped in GroupOptions options)
CompositionGroup Group(scoped in GroupOptions options);
Opens a group and applies its presentation properties. Draw through the same context only when the returned scope's Xui.Core.Canvas.Composition.Graphics.CompositionGroup.NeedsRedraw is true. Dispose the scope before drawing subsequent siblings.
Keys identify siblings by reference, not value equality. Use a stable reference, not a boxed value or a newly allocated key each frame. HasUpdates=false permits reuse; it never guarantees it. Export and immediate contexts always request drawing. A retained backend must also redraw when it lacks valid content. Reusing a group reuses its entire subtree, so HasUpdates must include relevant descendant changes. Presentation changes are processed even when content can be reused. HasUpdates=true must request drawing; it is also used by capture middleware to force both the display and export branches to accept the same drawing commands. Groups inherit drawing state and restore it on disposal, with the same path and state semantics as Save/Restore. Bounds do not change the coordinate origin. In a view-backed group, issue direct drawing before declaring child surfaces. To draw above those children, declare a separate overlay group. Retained backends reject drawing that violates this ordering instead of silently changing its depth. An inherited arbitrary canvas clip may require flattening a surface into its parent; that fallback requests drawing on every frame. Prefer group bounds clipping when native composition and content reuse are needed.
Example
using var group = context.Group(new GroupOptions
{
Key = this,
HasUpdates = HasRenderUpdates,
Bounds = Frame
});
if (group.NeedsRedraw)
DrawContent(context);
void ICompositionContext.ValidateGpuSurface(scoped in GroupOptions options)
static void ValidateGpuSurface(scoped in GroupOptions options);
Validates GPU identity and bounds before a backend changes state.
interface IContext
Represents a 2D drawing context for the Xui Canvas, modeled after the HTML5 Canvas 2D context API. This interface aggregates all sub-contexts responsible for different aspects of 2D rendering, including state, drawing primitives, text, images, transformations, and resource management.
public interface IContext : IMeasureContext, IStateContext, ISymbolContext, ICompositionContext, IFilterContext, IPenContext, IPathDrawingContext, IRectDrawingContext, ITextDrawingContext, IImageDrawingContext, ITransformContext, IDisposable
{
}
interface IFilterContext
Controls source-color adjustment when selecting canvas paints.
Set the filter before SetFill or SetStroke. It transforms solid colors and gradient stop colors as the paint is selected, including paints used for text. Existing paints and images are unchanged. The filter replaces the previous adjustment and participates in Save/Restore.
public interface IFilterContext
{
void SetFilter();
void SetFilter(Brightness brightness);
}
void IFilterContext.SetFilter()
void SetFilter();
Disables adjustment for subsequently selected paints.
void IFilterContext.SetFilter(Brightness brightness)
void SetFilter(Brightness brightness);
Sets the brightness of subsequently selected paints.
interface IFontSource
Supplies declared application fonts and loads their bytes on demand. A platform must fall back to its installed font catalogue when no resource exactly matches a request.
public interface IFontSource
{
IEnumerable<FontResource> Resources { get; }
bool TryGet(in Font font, out FontResource resource);
ReadOnlyMemory<byte> Load(in FontResource resource);
}
ReadOnlyMemory<byte> IFontSource.Load(in FontResource resource)
ReadOnlyMemory<byte> Load(in FontResource resource);
Loads a resource's bytes when a consumer needs them.
IEnumerable<FontResource> IFontSource.Resources
IEnumerable<FontResource> Resources { get; }
Gets all declared resources without loading their data.
bool IFontSource.TryGet(in Font font, out FontResource resource)
bool TryGet(in Font font, out FontResource resource);
Finds the exact application-provided face for a request.
interface IGlyphPathBuilder
A lightweight interface for constructing TrueType glyph paths using move, line, curve, and close commands.
Glyphs in TrueType fonts use quadratic Bézier curves with optional off-curve control points. This interface is intended for glyph outlines and font rendering engines.
public interface IGlyphPathBuilder
{
void MoveTo(Point to);
void LineTo(Point to);
void CurveTo(Point control, Point to);
void ClosePath();
}
void IGlyphPathBuilder.ClosePath()
void ClosePath();
Closes the current path contour.
void IGlyphPathBuilder.CurveTo(Point control, Point to)
void CurveTo(Point control, Point to);
Draws a quadratic Bézier curve using a control point and end point.
void IGlyphPathBuilder.LineTo(Point to)
void LineTo(Point to);
Draws a straight line to the specified point.
void IGlyphPathBuilder.MoveTo(Point to)
void MoveTo(Point to);
Begins a new sub-path at the specified point.
interface IImage
Represents a decoded, GPU-resident image. Acts as a self-loading resource handle — analogous to HTMLImageElement in the browser.
Acquire instances via GetService(typeof(IImage)) on any Xui.Core.UI.View. Then set the source with Xui.Core.Canvas.IImage.Load(System.String) (sync-if-cached) or Xui.Core.Canvas.IImage.LoadAsync(System.String) for first-time remote or large assets.
public interface IImage
{
Size Size { get; }
void Load(string uri);
Task LoadAsync(string uri);
void LoadPixels(int width, int height, ReadOnlySpan<byte> bgra32Data);
}
void IImage.Load(string uri)
void Load(string uri);
Loads the image from uri. Returns immediately if the image is already in the platform catalog. For local packaged assets this may block on first call; prefer Xui.Core.Canvas.IImage.LoadAsync(System.String) for anything that could be slow.
Task IImage.LoadAsync(string uri)
Task LoadAsync(string uri);
Loads the image from uri on a background thread. The returned task completes once the image is decoded and GPU-resident. Subsequent Xui.Core.Canvas.IImage.Load(System.String) calls with the same URI return instantly from cache.
void IImage.LoadPixels(int width, int height, ReadOnlySpan<byte> bgra32Data)
void LoadPixels(int width, int height, ReadOnlySpan<byte> bgra32Data);
Uploads raw CPU pixel data into this image, replacing any previously loaded content. bgra32Data must contain width * height * 4 bytes in BGRA order (B at the lowest address), matching DXGI_FORMAT_B8G8R8A8_UNORM. Default implementation is a no-op on platforms that do not support pixel upload.
Size IImage.Size
Size Size { get; }
Intrinsic size of the image in points. Returns Xui.Core.Math2D.Size.Empty until loaded.
interface IImageDrawingContext
Defines methods for drawing images onto the canvas. Mirrors the drawImage API from the HTML5 Canvas 2D context. https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage
public interface IImageDrawingContext
{
void DrawImage(IImage image, Rect dest);
void DrawImage(IImage image, Rect dest, nfloat opacity);
void DrawImage(IImage image, Rect source, Rect dest, nfloat opacity);
}
void IImageDrawingContext.DrawImage(IImage image, Rect dest)
void DrawImage(IImage image, Rect dest);
Draws the entire image scaled to fit dest at full opacity.
void IImageDrawingContext.DrawImage(IImage image, Rect dest, NFloat opacity)
void DrawImage(IImage image, Rect dest, nfloat opacity);
Draws the entire image scaled to fit dest at the given opacity.
void IImageDrawingContext.DrawImage(IImage image, Rect source, Rect dest, NFloat opacity)
void DrawImage(IImage image, Rect source, Rect dest, nfloat opacity);
Draws the sub-region source of image scaled to fit dest at the given opacity. Mirrors the 9-argument form of drawImage in the HTML5 Canvas API.
interface IMeasureContext
Defines a measurement context that provides access to platform-specific text metrics, supports subpixel snapping for layout precision, and enables accurate text size calculations using the underlying rendering engine's font rasterization and shaping systems.
public interface IMeasureContext : ITextMeasureContext
{
}
interface IPathBuilder
Defines methods for constructing paths, following the HTML5 Canvas path API model. Reference: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D#paths
public interface IPathBuilder : IGlyphPathBuilder
{
void BeginPath();
void CurveTo(Point cp1, Point cp2, Point to);
void Arc(Point center, nfloat radius, nfloat startAngle, nfloat endAngle, Winding winding = Winding.ClockWise);
void ArcTo(Point cp1, Point cp2, nfloat radius);
void Ellipse(Point center, nfloat radiusX, nfloat radiusY, nfloat rotation, nfloat startAngle, nfloat endAngle, Winding winding = Winding.ClockWise);
void Rect(Rect rect);
void RoundRect(Rect rect, nfloat radius);
void RoundRect(Rect rect, CornerRadius radius);
}
void IPathBuilder.Arc(Point center, NFloat radius, NFloat startAngle, NFloat endAngle, Winding winding = Winding.ClockWise)
void Arc(Point center, nfloat radius, nfloat startAngle, nfloat endAngle, Winding winding = Winding.ClockWise);
Adds an arc to the path centered at the specified point.
center— Center of the arc.radius— Radius of the arc.startAngle— Start angle in radians.endAngle— End angle in radians.winding— Direction in which the arc is drawn.
void IPathBuilder.ArcTo(Point cp1, Point cp2, NFloat radius)
void ArcTo(Point cp1, Point cp2, nfloat radius);
Adds an arc to the path, connecting two tangents defined by control points.
cp1— First control point.cp2— Second control point.radius— Arc radius.
void IPathBuilder.BeginPath()
void BeginPath();
Begins a new path by resetting the current path list.
void IPathBuilder.CurveTo(Point cp1, Point cp2, Point to)
void CurveTo(Point cp1, Point cp2, Point to);
Draws a cubic Bézier curve from the current point to the specified point, using two control points.
cp1— First control point.cp2— Second control point.to— End point.
void IPathBuilder.Ellipse(Point center, NFloat radiusX, NFloat radiusY, NFloat rotation, NFloat startAngle, NFloat endAngle, Winding winding = Winding.ClockWise)
void Ellipse(Point center, nfloat radiusX, nfloat radiusY, nfloat rotation, nfloat startAngle, nfloat endAngle, Winding winding = Winding.ClockWise);
Adds an elliptical arc to the path.
center— Center of the ellipse.radiusX— Horizontal radius.radiusY— Vertical radius.rotation— Rotation of the ellipse, in radians.startAngle— Start angle in radians.endAngle— End angle in radians.winding— Direction in which the arc is drawn.
void IPathBuilder.Rect(Rect rect)
void Rect(Rect rect);
Adds a rectangle path to the current path.
rect— The rectangle to add.
void IPathBuilder.RoundRect(Rect rect, NFloat radius)
void RoundRect(Rect rect, nfloat radius);
Adds a rounded rectangle path with a uniform radius.
rect— The rectangle to round.radius— Corner radius.
void IPathBuilder.RoundRect(Rect rect, CornerRadius radius)
void RoundRect(Rect rect, CornerRadius radius);
Adds a rounded rectangle path with per-corner radii.
rect— The rectangle to round.radius— Corner radius object defining each corner.
interface IPathClipping
Defines methods for clipping using a path, following the HTML5 Canvas path API model. Reference: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D#paths
public interface IPathClipping
{
void Clip();
}
void IPathClipping.Clip()
void Clip();
Sets the current clipping region to the current path. Subsequent drawing operations are clipped to this region.
interface IPathDrawing
Defines methods for drawing a constructed path, following the HTML5 Canvas path API model. Reference: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D#paths
public interface IPathDrawing
{
void Fill(FillRule rule = FillRule.NonZero);
void Stroke();
}
void IPathDrawing.Fill(FillRule rule = FillRule.NonZero)
void Fill(FillRule rule = FillRule.NonZero);
Fills the current path using the specified fill rule.
rule— The fill rule to use (NonZero or EvenOdd).
void IPathDrawing.Stroke()
void Stroke();
Strokes the current path using the current stroke style.
interface IPathDrawingContext
Defines methods for constructing and rendering 2D paths, following the HTML5 Canvas path API model. Reference: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D#paths
public interface IPathDrawingContext : IPathBuilder, IPathDrawing, IPathClipping
{
}
interface IPenContext
Defines properties and methods for controlling stroke and fill styles in a 2D drawing context, including line caps, joins, width, dashes, and brush settings for fill and stroke.
public interface IPenContext
{
nfloat GlobalAlpha { set; }
LineCap LineCap { set; }
LineJoin LineJoin { set; }
nfloat LineWidth { set; }
nfloat MiterLimit { set; }
nfloat LineDashOffset { set; }
void SetLineDash(ReadOnlySpan<nfloat> segments);
void SetStroke(Color color);
void SetStroke(LinearGradient linearGradient);
void SetStroke(RadialGradient radialGradient);
void SetFill(Color color);
void SetFill(LinearGradient linearGradient);
void SetFill(RadialGradient radialGradient);
void SetFill(ImagePattern pattern);
void SetStroke(ImagePattern pattern);
}
NFloat IPenContext.GlobalAlpha
nfloat GlobalAlpha { set; }
Sets the global alpha value for all drawing operations. Range: 0.0 (fully transparent) to 1.0 (fully opaque).
LineCap IPenContext.LineCap
LineCap LineCap { set; }
Sets the style of line caps used for strokes.
NFloat IPenContext.LineDashOffset
nfloat LineDashOffset { set; }
Sets the phase offset for the start of the dash pattern.
LineJoin IPenContext.LineJoin
LineJoin LineJoin { set; }
Sets the style of line joins between segments.
NFloat IPenContext.LineWidth
nfloat LineWidth { set; }
Sets the width of stroked lines, in user space units.
NFloat IPenContext.MiterLimit
nfloat MiterLimit { set; }
Sets the miter limit ratio for miter joins. If the ratio of miter length to line width exceeds this value, a bevel join is used instead.
void IPenContext.SetFill(Color color)
void SetFill(Color color);
Sets the fill style to a solid color.
color— The fill color.
void IPenContext.SetFill(ImagePattern pattern)
void SetFill(ImagePattern pattern);
Sets the fill style to a tiled image pattern, equivalent to ctx.fillStyle = ctx.createPattern(image, repetition) in the browser.
void IPenContext.SetFill(LinearGradient linearGradient)
void SetFill(LinearGradient linearGradient);
Sets the fill style to a linear gradient.
linearGradient— The gradient to use for filling shapes.
void IPenContext.SetFill(RadialGradient radialGradient)
void SetFill(RadialGradient radialGradient);
Sets the fill style to a radial gradient.
radialGradient— The gradient to use for filling shapes.
void IPenContext.SetLineDash(ReadOnlySpan<NFloat> segments)
void SetLineDash(ReadOnlySpan<nfloat> segments);
Sets the dash pattern used for stroking lines. Each element in the span represents a dash or gap length, alternating.
segments— A sequence of dash and gap lengths.
void IPenContext.SetStroke(Color color)
void SetStroke(Color color);
Sets the stroke style to a solid color.
color— The stroke color.
void IPenContext.SetStroke(ImagePattern pattern)
void SetStroke(ImagePattern pattern);
Sets the stroke style to a tiled image pattern.
void IPenContext.SetStroke(LinearGradient linearGradient)
void SetStroke(LinearGradient linearGradient);
Sets the stroke style to a linear gradient.
linearGradient— The gradient to use for stroking paths.
void IPenContext.SetStroke(RadialGradient radialGradient)
void SetStroke(RadialGradient radialGradient);
Sets the stroke style to a radial gradient.
radialGradient— The gradient to use for stroking paths.
interface IRectDrawingContext
Provides convenience methods for drawing filled and stroked rectangles, similar to the fillRect() and strokeRect() functions in the HTML5 Canvas API.
public interface IRectDrawingContext
{
void StrokeRect(Rect rect);
void FillRect(Rect rect);
}
void IRectDrawingContext.FillRect(Rect rect)
void FillRect(Rect rect);
Fills the specified rectangle using the current fill style.
rect— The rectangle to fill.
void IRectDrawingContext.StrokeRect(Rect rect)
void StrokeRect(Rect rect);
Draws the outline of the specified rectangle using the current stroke style.
rect— The rectangle to stroke.
interface IStateContext
Provides methods to save and restore the current drawing state, including styles, transforms, and clipping paths. Mirrors the behavior of the HTML5 Canvas save() and restore() methods.
public interface IStateContext
{
void Save();
void Restore();
}
void IStateContext.Restore()
void Restore();
Pops the top state off the state stack and restores it. Any modifications made since the last Xui.Core.Canvas.IStateContext.Save are discarded.
void IStateContext.Save()
void Save();
Pushes the current drawing state onto the state stack. This includes styles, transformations, clipping paths, etc.
interface ISymbolContext
Defines reusable vector drawings independently of their placements.
Example
using (var symbol = context.Symbol(new SymbolOptions { Key = chair, Bounds = (0, 0, 40, 40) }))
{
if (symbol.NeedsDrawing)
{
symbol.Context.SetFill(Colors.Gray);
symbol.Context.FillRect((4, 4, 32, 32));
}
}
context.Save();
context.Translate((100, 50));
context.UseSymbol(chair);
context.Restore();
Definitions start with default pen, alpha and text state. Placements inherit the current transform, clip and brightness, and restore enclosing paint/text state afterwards. Use relative transforms inside definitions. Native view groups, GPU surfaces, absolute SetTransform and nested symbols are not supported inside a symbol. On recording failure, call the scope's Cancel method before disposing it. Cache storage follows reference lifetime; ReleaseSymbol drops a key without invalidating already-recorded placements.
public interface ISymbolContext
{
SymbolScope Symbol(scoped in SymbolOptions options);
void UseSymbol(object key);
void ReleaseSymbol(object key);
void DrawSymbol(SymbolContent content);
}
void ISymbolContext.DrawSymbol(SymbolContent content)
void DrawSymbol(SymbolContent content);
Backend playback entry point. Retained contexts record a reference; native contexts may compile it. The default implements vector command replay for any IContext.
void ISymbolContext.ReleaseSymbol(object key)
void ReleaseSymbol(object key);
Forgets a definition. Previously recorded placements retain their immutable content.
SymbolScope ISymbolContext.Symbol(scoped in SymbolOptions options)
SymbolScope Symbol(scoped in SymbolOptions options);
Opens a definition without drawing it. When NeedsDrawing is true, draw into the returned scope's Context, then dispose the scope before calling UseSymbol. Keys use reference identity. A new context may request the definition again.
void ISymbolContext.UseSymbol(object key)
void UseSymbol(object key);
Draws a completed definition under the current transform and clip.
interface ITextDrawingContext
Defines methods for drawing text onto the canvas, including alignment and baseline options. Mirrors the HTML5 Canvas 2D text API for fillText(). Also provides access to text measurement via Xui.Core.Canvas.ITextMeasureContext.
public interface ITextDrawingContext : ITextMeasureContext
{
TextAlign TextAlign { set; }
TextBaseline TextBaseline { set; }
void FillText(string text, Point pos);
void FillText(ReadOnlySpan<char> text, Point pos);
void FillText(FillTextInterpolatedStringHandler handler, Point pos);
}
void ITextDrawingContext.FillText(ReadOnlySpan<char> text, Point pos)
void FillText(ReadOnlySpan<char> text, Point pos);
Draws filled text at the specified position without allocating a string. Use with stackalloc and System.ISpanFormattable.TryFormat(System.Span{System.Char},System.Int32@,System.ReadOnlySpan{System.Char},System.IFormatProvider) for zero-allocation rendering.
text— The text characters to render.pos— The position at which to start rendering the text.
void ITextDrawingContext.FillText(string text, Point pos)
void FillText(string text, Point pos);
Draws filled text at the specified position using the current fill style and font settings.
text— The text string to render.pos— The position at which to start rendering the text.
void ITextDrawingContext.FillText(FillTextInterpolatedStringHandler handler, Point pos)
void FillText(FillTextInterpolatedStringHandler handler, Point pos);
Draws filled text from an interpolated string without heap-allocating the string. The compiler automatically prefers this overload for interpolated string arguments.
handler— The interpolated string handler that formats into a stack buffer.pos— The position at which to start rendering the text.
TextAlign ITextDrawingContext.TextAlign
TextAlign TextAlign { set; }
Sets the horizontal alignment of the text relative to the given position.
TextBaseline ITextDrawingContext.TextBaseline
TextBaseline TextBaseline { set; }
Sets the vertical alignment of the text relative to the given baseline.
interface ITextMeasureContext
Provides functionality for measuring text and setting font properties. Mirrors the measurement behavior of the HTML5 Canvas 2D context, but returns a full Xui.Core.Canvas.TextMetrics structure for advanced layout.
public interface ITextMeasureContext
{
TextMetrics MeasureText(string text);
TextMetrics MeasureText(ReadOnlySpan<char> text);
void SetFont(Font font);
int HitTestTextPosition(string text, nfloat x);
int HitTestTextPosition(ReadOnlySpan<char> text, nfloat x);
}
int ITextMeasureContext.HitTestTextPosition(ReadOnlySpan<char> text, NFloat x)
int HitTestTextPosition(ReadOnlySpan<char> text, nfloat x);
Returns the character index (caret position) in text closest to the given x coordinate, using the current font. The result ranges from 0 (before the first character) to text.Length (after the last character). The position snaps to whichever side of a character's midpoint x falls on.
text— The text to hit-test against.x— The horizontal offset to test, relative to the text origin.
Returns: The nearest caret position (0 to text.Length).
int ITextMeasureContext.HitTestTextPosition(string text, NFloat x)
int HitTestTextPosition(string text, nfloat x);
Returns the character index (caret position) in text closest to the given x coordinate, using the current font. The result ranges from 0 (before the first character) to text.Length (after the last character). The position snaps to whichever side of a character's midpoint x falls on.
text— The text to hit-test against.x— The horizontal offset to test, relative to the text origin.
Returns: The nearest caret position (0 to text.Length).
TextMetrics ITextMeasureContext.MeasureText(ReadOnlySpan<char> text)
TextMetrics MeasureText(ReadOnlySpan<char> text);
Measures the layout and bounding box metrics of the specified text without allocating a string.
text— The text characters to measure.
Returns: A Xui.Core.Canvas.TextMetrics structure containing both string-specific and font-wide metrics.
TextMetrics ITextMeasureContext.MeasureText(string text)
TextMetrics MeasureText(string text);
Measures the layout and bounding box metrics of the specified text string using the current font.
text— The text string to measure.
Returns: A Xui.Core.Canvas.TextMetrics structure containing both string-specific and font-wide metrics.
void ITextMeasureContext.SetFont(Font font)
void SetFont(Font font);
Sets the font used for all subsequent text drawing and measurement operations.
font— The font definition to apply.
interface ITransformContext
Provides methods for manipulating the current transformation matrix of the drawing context. This includes translation, scaling, rotation, and applying affine transformations. Mirrors the transformation API of the HTML5 Canvas 2D context.
public interface ITransformContext
{
void Translate(Vector vector);
void Rotate(nfloat angle);
void Scale(Vector vector);
void SetTransform(AffineTransform transform);
void Transform(AffineTransform matrix);
}
void ITransformContext.Rotate(NFloat angle)
void Rotate(nfloat angle);
Applies a clockwise rotation to the current transform.
angle— The rotation angle in radians.
void ITransformContext.Scale(Vector vector)
void Scale(Vector vector);
Applies a scaling transformation using the specified scaling factors.
vector— The scaling vector (sx, sy).
void ITransformContext.SetTransform(AffineTransform transform)
void SetTransform(AffineTransform transform);
Resets the current transformation matrix to the identity matrix, then replaces it with the specified transform. Equivalent to ctx.setTransform(...) in HTML5 Canvas.
transform— The new transformation matrix to apply.
void ITransformContext.Transform(AffineTransform matrix)
void Transform(AffineTransform matrix);
Multiplies the current transformation matrix by the specified matrix. This is equivalent to applying an additional transformation on top of the existing one.
matrix— The matrix to multiply with the current transform.
void ITransformContext.Translate(Vector vector)
void Translate(Vector vector);
Applies a translation by the specified vector. This offsets all subsequent drawing operations by the given amount.
vector— The translation vector (dx, dy).
ref struct ImagePattern
Describes an image-based fill or stroke pattern — the Canvas API equivalent of a CanvasPattern returned by createPattern(image, repetition).
Pass to Xui.Core.Canvas.IPenContext.SetFill(Xui.Core.Canvas.ImagePattern) or Xui.Core.Canvas.IPenContext.SetStroke(Xui.Core.Canvas.ImagePattern) to paint paths with a tiled image.
public ref struct ImagePattern
{
public IImage Image;
public PatternRepeat Repetition;
public ImagePattern(IImage image, PatternRepeat repetition = PatternRepeat.Repeat);
}
ImagePattern.ImagePattern(IImage image, PatternRepeat repetition = PatternRepeat.Repeat)
public ImagePattern(IImage image, PatternRepeat repetition = PatternRepeat.Repeat);
image— The source image (must be loaded before drawing).repetition— Tiling mode; defaults toXui.Core.Canvas.PatternRepeat.Repeat.
IImage ImagePattern.Image
public IImage Image;
The image to tile.
PatternRepeat ImagePattern.Repetition
public PatternRepeat Repetition;
How the image repeats beyond its natural bounds.
enum LineCap
Specifies the shape used at the ends of lines when stroking paths. Mirrors the lineCap property in the HTML5 Canvas API.
public enum LineCap
{
Butt = 0,
Round = 1,
Square = 2
}
LineCap.Butt
Butt = 0
The line ends exactly at the endpoint with no additional extension. This is the default.
LineCap.Round
Round = 1
The line ends with a semicircular extension, centered on the endpoint.
LineCap.Square
Square = 2
The line ends with a square extension equal to half the line width, extending beyond the endpoint.
enum LineJoin
Specifies how two connected lines are joined when stroking a path. Mirrors the lineJoin property in the HTML5 Canvas API.
public enum LineJoin
{
Miter = 0,
Round = 1,
Bevel = 2
}
LineJoin.Bevel
Bevel = 2
Lines are joined with a beveled corner by connecting the outer corners of the strokes.
LineJoin.Miter
Miter = 0
Lines are joined with a sharp corner or extended miter, depending on the miter limit.
LineJoin.Round
Round = 1
Lines are joined with a circular arc, creating a rounded corner.
readonly struct LineMetrics
Represents text layout metrics that depend on the specific string being measured. Includes actual bounding box and visual advance width.
public readonly struct LineMetrics
{
public readonly nfloat Width;
public readonly nfloat ActualBoundingBoxLeft;
public readonly nfloat ActualBoundingBoxRight;
public readonly nfloat ActualBoundingBoxAscent;
public readonly nfloat ActualBoundingBoxDescent;
public nfloat ActualHeight { get; }
public LineMetrics(nfloat width, nfloat left, nfloat right, nfloat ascent, nfloat descent);
}
LineMetrics.LineMetrics(NFloat width, NFloat left, NFloat right, NFloat ascent, NFloat descent)
public LineMetrics(nfloat width, nfloat left, nfloat right, nfloat ascent, nfloat descent);
Initializes a new Xui.Core.Canvas.LineMetrics instance.
width— Advance width of the rendered text.left— Furthest left pixel offset relative to the origin.right— Furthest right pixel offset relative to the origin.ascent— Maximum pixel height above the baseline.descent— Maximum pixel depth below the baseline.
NFloat LineMetrics.ActualBoundingBoxAscent
public readonly nfloat ActualBoundingBoxAscent;
Distance from the baseline to the topmost pixel of any glyph.
NFloat LineMetrics.ActualBoundingBoxDescent
public readonly nfloat ActualBoundingBoxDescent;
Distance from the baseline to the bottommost pixel of any glyph.
NFloat LineMetrics.ActualBoundingBoxLeft
public readonly nfloat ActualBoundingBoxLeft;
Distance from the text origin to the furthest left pixel of any glyph. May be negative for italic or overhanging glyphs.
NFloat LineMetrics.ActualBoundingBoxRight
public readonly nfloat ActualBoundingBoxRight;
Distance from the text origin to the furthest right pixel of any glyph.
NFloat LineMetrics.ActualHeight
public nfloat ActualHeight { get; }
Full height of the visual bounding box (ascent + descent).
NFloat LineMetrics.Width
public readonly nfloat Width;
Advance width of the string, including kerning and shaping. This is how far the cursor should advance after drawing the text.
ref struct LinearGradient
Represents a linear gradient brush that transitions between colors along a straight line, following the same behavior as the HTML5 Canvas createLinearGradient().
public ref struct LinearGradient
{
public Point StartPoint;
public Point EndPoint;
public ReadOnlySpan<GradientStop> GradientStops;
public LinearGradient(Point start, Point end, ReadOnlySpan<GradientStop> gradient);
}
LinearGradient.LinearGradient(Point start, Point end, ReadOnlySpan<GradientStop> gradient)
public LinearGradient(Point start, Point end, ReadOnlySpan<GradientStop> gradient);
Creates a new Xui.Core.Canvas.LinearGradient with the given start and end points and gradient stops.
start— The start point of the gradient.end— The end point of the gradient.gradient— A span of gradient stops sorted by offset.
Point LinearGradient.EndPoint
public Point EndPoint;
The ending point of the gradient, in user space coordinates.
ReadOnlySpan<GradientStop> LinearGradient.GradientStops
public ReadOnlySpan<GradientStop> GradientStops;
The sequence of gradient stops that define color transitions along the line. Offsets are typically in the range [0, 1].
Point LinearGradient.StartPoint
public Point StartPoint;
The starting point of the gradient, in user space coordinates.
enum PaintStyle
Specifies the type of brush or fill style used for painting shapes or strokes. Helps distinguish between solid colors and gradient fills.
public enum PaintStyle
{
SolidColor = 0,
LinearGradient = 1,
RadialGradient = 2,
BitmapBrush = 3
}
PaintStyle.BitmapBrush
BitmapBrush = 3
A repeating bitmap pattern (equivalent to createPattern(image, "repeat")).
PaintStyle.LinearGradient
LinearGradient = 1
A linear gradient that transitions colors along a straight line.
PaintStyle.RadialGradient
RadialGradient = 2
A radial gradient that transitions colors outward in a circular or elliptical shape.
PaintStyle.SolidColor
SolidColor = 0
A single, uniform color.
class Path2D
A serialized path that stores drawing commands in a compact byte buffer and replays them into any Xui.Core.Canvas.IPathBuilder. Use Xui.Core.Canvas.Path2D.Visit``1(``0) to replay recorded commands.
public class Path2D : IPathBuilder
{
public Path2D(int initialCapacity = 256);
public void BeginPath();
public void MoveTo(Point to);
public void LineTo(Point to);
public void ClosePath();
public void CurveTo(Point cp1, Point to);
public void CurveTo(Point cp1, Point cp2, Point to);
public void Arc(Point center, nfloat radius, nfloat startAngle, nfloat endAngle, Winding winding = Winding.ClockWise);
public void ArcTo(Point cp1, Point cp2, nfloat radius);
public void Ellipse(Point center, nfloat radiusX, nfloat radiusY, nfloat rotation, nfloat startAngle, nfloat endAngle, Winding winding = Winding.ClockWise);
public void Rect(Rect rect);
public void RoundRect(Rect rect, nfloat radius);
public void RoundRect(Rect rect, CornerRadius radius);
public void Visit<T>(T sink)
where T : IPathBuilder;
}
Path2D.Path2D(int initialCapacity = 256)
public Path2D(int initialCapacity = 256);
Initializes a new Xui.Core.Canvas.Path2D with the specified initial byte-buffer capacity.
initialCapacity— Initial buffer size in bytes. Grows automatically as needed.
void Path2D.Arc(Point center, NFloat radius, NFloat startAngle, NFloat endAngle, Winding winding = Winding.ClockWise)
public void Arc(Point center, nfloat radius, nfloat startAngle, nfloat endAngle, Winding winding = Winding.ClockWise);
Adds an arc to the path centered at the specified point.
center— Center of the arc.radius— Radius of the arc.startAngle— Start angle in radians.endAngle— End angle in radians.winding— Direction in which the arc is drawn.
void Path2D.ArcTo(Point cp1, Point cp2, NFloat radius)
public void ArcTo(Point cp1, Point cp2, nfloat radius);
Adds an arc to the path, connecting two tangents defined by control points.
cp1— First control point.cp2— Second control point.radius— Arc radius.
void Path2D.BeginPath()
public void BeginPath();
Clears all recorded path commands, resetting the path to empty.
void Path2D.ClosePath()
public void ClosePath();
Closes the current path contour.
void Path2D.CurveTo(Point cp1, Point to)
public void CurveTo(Point cp1, Point to);
Draws a quadratic Bézier curve using a control point and end point.
void Path2D.CurveTo(Point cp1, Point cp2, Point to)
public void CurveTo(Point cp1, Point cp2, Point to);
Draws a cubic Bézier curve from the current point to the specified point, using two control points.
cp1— First control point.cp2— Second control point.to— End point.
void Path2D.Ellipse(Point center, NFloat radiusX, NFloat radiusY, NFloat rotation, NFloat startAngle, NFloat endAngle, Winding winding = Winding.ClockWise)
public void Ellipse(Point center, nfloat radiusX, nfloat radiusY, nfloat rotation, nfloat startAngle, nfloat endAngle, Winding winding = Winding.ClockWise);
Adds an elliptical arc to the path.
center— Center of the ellipse.radiusX— Horizontal radius.radiusY— Vertical radius.rotation— Rotation of the ellipse, in radians.startAngle— Start angle in radians.endAngle— End angle in radians.winding— Direction in which the arc is drawn.
void Path2D.LineTo(Point to)
public void LineTo(Point to);
Draws a straight line to the specified point.
void Path2D.MoveTo(Point to)
public void MoveTo(Point to);
Begins a new sub-path at the specified point.
void Path2D.Rect(Rect rect)
public void Rect(Rect rect);
Adds a rectangle path to the current path.
rect— The rectangle to add.
void Path2D.RoundRect(Rect rect, NFloat radius)
public void RoundRect(Rect rect, nfloat radius);
Adds a rounded rectangle path with a uniform radius.
rect— The rectangle to round.radius— Corner radius.
void Path2D.RoundRect(Rect rect, CornerRadius radius)
public void RoundRect(Rect rect, CornerRadius radius);
Adds a rounded rectangle path with per-corner radii.
rect— The rectangle to round.radius— Corner radius object defining each corner.
void Path2D.Visit<T>(T sink)
public void Visit<T>(T sink)
where T : IPathBuilder;
Replays all recorded path commands into the given Xui.Core.Canvas.IPathBuilder.
sink— The path builder to receive the commands.
enum PatternRepeat
Controls how an image pattern tiles, following the same values as the repetition argument to the browser's createPattern(image, repetition).
public enum PatternRepeat
{
Repeat,
RepeatX,
RepeatY,
NoRepeat,
}
PatternRepeat.NoRepeat
NoRepeat
Drawn once — no tiling in either direction.
PatternRepeat.Repeat
Repeat
Tiles in both directions.
PatternRepeat.RepeatX
RepeatX
Tiles horizontally only; clamped vertically.
PatternRepeat.RepeatY
RepeatY
Tiles vertically only; clamped horizontally.
ref struct RadialGradient
Represents a radial gradient brush that transitions colors outward from one circle to another, similar to createRadialGradient() in the HTML5 Canvas API.
public ref struct RadialGradient
{
public Point StartCenter;
public nfloat StartRadius;
public Point EndCenter;
public nfloat EndRadius;
public ReadOnlySpan<GradientStop> GradientStops;
public RadialGradient(Point startCenter, nfloat startRadius, Point endCenter, nfloat endRadius, ReadOnlySpan<GradientStop> gradientStops);
public RadialGradient(Point center, nfloat radius, ReadOnlySpan<GradientStop> gradientStops);
}
RadialGradient.RadialGradient(Point center, NFloat radius, ReadOnlySpan<GradientStop> gradientStops)
public RadialGradient(Point center, nfloat radius, ReadOnlySpan<GradientStop> gradientStops);
Initializes a radial gradient from a single point and radius, fading outward from a solid center. This is equivalent to setting the start radius to zero and both centers to the same point.
center— Center point of the gradient.radius— Radius of the gradient spread.gradientStops— Span of color stops defining the gradient transition.
RadialGradient.RadialGradient(Point startCenter, NFloat startRadius, Point endCenter, NFloat endRadius, ReadOnlySpan<GradientStop> gradientStops)
public RadialGradient(Point startCenter, nfloat startRadius, Point endCenter, nfloat endRadius, ReadOnlySpan<GradientStop> gradientStops);
Initializes a radial gradient that transitions between two circles.
startCenter— Center of the inner circle.startRadius— Radius of the inner circle.endCenter— Center of the outer circle.endRadius— Radius of the outer circle.gradientStops— Span of color stops defining the gradient transition.
Point RadialGradient.EndCenter
public Point EndCenter;
The center point of the ending circle (outer circle).
NFloat RadialGradient.EndRadius
public nfloat EndRadius;
The radius of the ending circle (outer circle), defining the spread of the gradient.
ReadOnlySpan<GradientStop> RadialGradient.GradientStops
public ReadOnlySpan<GradientStop> GradientStops;
A sequence of color stops defining how colors are interpolated from the inner to the outer circle. Offsets are typically in the range [0, 1].
Point RadialGradient.StartCenter
public Point StartCenter;
The center point of the starting circle (inner circle).
NFloat RadialGradient.StartRadius
public nfloat StartRadius;
The radius of the starting circle (inner circle), usually 0 for solid centers.
class RoundedRect
Utility for clamping corner radii to fit within a rectangle, following the CSS Backgrounds and Borders Module Level 3, Section 5.5 "Overlapping Curves". When the sum of adjacent radii exceeds a side's length, all radii are scaled down proportionally so that curves never overlap.
public static class RoundedRect
{
public static CornerRadius Clamp(Size size, CornerRadius radius);
public static nfloat Clamp(Size size, nfloat radius);
}
NFloat RoundedRect.Clamp(Size size, NFloat radius)
public static nfloat Clamp(Size size, nfloat radius);
Returns a uniform radius clamped to fit within the given size. Equivalent to min(radius, width / 2, height / 2).
size— The dimensions of the rectangle.radius— The desired uniform corner radius.
Returns: The clamped radius value.
CornerRadius RoundedRect.Clamp(Size size, CornerRadius radius)
public static CornerRadius Clamp(Size size, CornerRadius radius);
Returns a Xui.Core.Canvas.CornerRadius whose values are clamped so that adjacent corners do not overlap on any side of a rectangle of the given size.
Algorithm: compute f = min(1, L_i / S_i) over all four sides, where L_i is the side length and S_i is the sum of the two corner radii on that side. Then multiply every radius by f.
size— The dimensions of the rectangle.radius— The desired corner radii.
Returns: Corner radii scaled to fit within the rectangle.
enum TextAlign
Specifies the horizontal alignment of text relative to the drawing position. Mirrors the textAlign property in the HTML5 Canvas 2D API.
public enum TextAlign
{
Start,
End,
Left,
Right,
Center
}
TextAlign.Center
Center
Centers the text horizontally around the drawing position.
TextAlign.End
End
Aligns text to the end of the writing direction (right for LTR, left for RTL).
TextAlign.Left
Left
Aligns text to the left, regardless of writing direction.
TextAlign.Right
Right
Aligns text to the right, regardless of writing direction.
TextAlign.Start
Start
Aligns text to the start of the writing direction (left for LTR, right for RTL).
enum TextBaseline
Specifies the vertical alignment of text relative to the drawing position. Mirrors the textBaseline property in the HTML5 Canvas 2D API.
public enum TextBaseline
{
Top,
Hanging,
Middle,
Alphabetic,
Ideographic,
Bottom
}
TextBaseline.Alphabetic
Alphabetic
The alphabetic baseline (default for Latin scripts) is aligned with the drawing position.
TextBaseline.Bottom
Bottom
The bottom of the em box is aligned with the drawing position.
TextBaseline.Hanging
Hanging
The hanging baseline is aligned with the drawing position (used in some scripts like Devanagari).
TextBaseline.Ideographic
Ideographic
The ideographic baseline is aligned with the drawing position (used in scripts like Chinese or Japanese).
TextBaseline.Middle
Middle
The middle of the text (roughly half the em height) is aligned with the drawing position.
TextBaseline.Top
Top
The top of the em box is aligned with the drawing position.
readonly struct TextMetrics
Composite structure combining string-specific and font-specific text metrics. Used for precise layout, alignment, and rendering across all platforms.
public readonly struct TextMetrics
{
public readonly LineMetrics Line;
public readonly FontMetrics Font;
public TextMetrics(LineMetrics line, FontMetrics font);
public Rect BoundingBox { get; }
public Size Size { get; }
public static implicit operator Size(TextMetrics metrics);
}
TextMetrics.TextMetrics(LineMetrics line, FontMetrics font)
public TextMetrics(LineMetrics line, FontMetrics font);
Creates a new composite text metrics structure.
Rect TextMetrics.BoundingBox
public Rect BoundingBox { get; }
Returns the visual bounding box of the text string, relative to the origin. X may be negative for glyphs that extend left of the starting point.
FontMetrics TextMetrics.Font
public readonly FontMetrics Font;
Metrics derived from the current font and size, independent of input string.
LineMetrics TextMetrics.Line
public readonly LineMetrics Line;
Metrics specific to the given text string (shaping, kerning, bounding box).
Size TextMetrics.Size
public Size Size { get; }
The measured size of the text.
TextMetrics.implicit operator Size(TextMetrics metrics)
public static implicit operator Size(TextMetrics metrics);
Implicitly converts the text metrics to a Xui.Core.Canvas.TextMetrics.Size, using the advance width and total height of the string. The width corresponds to how far the cursor should advance, not the visual width.
class TextMetricsCache
Bounded LRU of string measurements. Text keys use object identity, so stable labels never need character hashing or comparison. All storage is allocated once; misses and eviction do not allocate cache entries. Each measurement context owns its cache; clear it if native font resolution changes.
public sealed class TextMetricsCache
{
public const int DefaultCapacity = 128;
public TextMetricsCache(int capacity = DefaultCapacity);
public bool TryGet(string text, in Font font, TextAlign align, TextBaseline baseline, out TextMetrics metrics);
public void Set(string text, in Font font, TextAlign align, TextBaseline baseline, in TextMetrics metrics);
public void Clear();
}
TextMetricsCache.TextMetricsCache(int capacity = 128)
public TextMetricsCache(int capacity = DefaultCapacity);
Creates a context-owned cache with fixed storage.
void TextMetricsCache.Clear()
public void Clear();
Clears measurements and releases all retained string and font references.
int TextMetricsCache.DefaultCapacity
public const int DefaultCapacity = 128;
The standard maximum number of retained string measurements.
void TextMetricsCache.Set(string text, in Font font, TextAlign align, TextBaseline baseline, in TextMetrics metrics)
public void Set(string text, in Font font, TextAlign align, TextBaseline baseline, in TextMetrics metrics);
Stores metrics, replacing the least recently used entry when full.
bool TextMetricsCache.TryGet(string text, in Font font, TextAlign align, TextBaseline baseline, out TextMetrics metrics)
public bool TryGet(string text, in Font font, TextAlign align, TextBaseline baseline, out TextMetrics metrics);
Looks up the same string instance and measurement settings, updating its recency.
enum Winding
Specifies the direction in which arcs or elliptical curves are drawn, affecting fill and stroke behavior in path-based rendering.
public enum Winding : int
{
ClockWise = 1,
CounterClockWise = 0
}
Winding.ClockWise
ClockWise = 1
The path is drawn in a clockwise direction. This is the default in most canvas and geometry operations.
Winding.CounterClockWise
CounterClockWise = 0
The path is drawn in a counter-clockwise direction.