public readonly record struct NineSliceFour inset edges, and the cut of a rectangle into the nine they describe.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
A nine-slice is rectangle arithmetic, which is why it is here and not beside either of its callers. Two consumers need exactly the same nine pairs of rectangles — a user interface stretching a panel's background and a renderer stretching a sprite — and they cannot reference each other: Vixen.Ui describes a frame without a device and Vixen.Rendering draws without knowing what an element tree is. The alternative was the same twenty lines in both, which is two places for the corner convention to disagree.
⚠ Unitless on purpose. The same four numbers are texels when they cut a texture region, document pixels when they cut a destination box, and zero-to-one when they cut a UV rectangle — and Scaled is what moves between them. A type that named its unit would need three of itself, and the split is identical in all three.
The order is CSS's: left, top, right, bottom is not what a reader expects, but it is what border-image-slice, Thickness and every stylesheet in the repository already write, and a fifth ordering in the same codebase is a mistake nobody will see in a diff — the numbers are all floats and swapping two of them still compiles.
Fields and properties (10)
public float LeftHow far the left column reaches in from the left edge.
public float TopHow far the top row reaches down from the top edge.
public float RightHow far the right column reaches in from the right edge.
public float BottomHow far the bottom row reaches up from the bottom edge.
public const int CellCountHow many cells Split writes.
public const int CentreWhere the middle cell lands in a split, for a caller that draws it separately.
public static NineSlice NoneNo inset at all: one cell covering the whole rectangle.
public bool IsEmptyWhether there is nothing to cut, so the rectangle is its own single cell.
public float HorizontalWhat the two columns of border take up together.
public float VerticalWhat the two rows of border take up together.
Methods (5)
public NineSlice(float Left, float Top, float Right, float Bottom)Four inset edges, and the cut of a rectangle into the nine they describe.
public static NineSlice Uniform(float amount)The same inset on all four edges.
public NineSlice Scaled(float x, float y)The same inset measured in different units.
public NineSlice Fit(float width, float height)The inset shrunk until its borders fit inside a box, preserving their proportions.
public void Split(Rectangle box, Span<Rectangle> into)Cuts a rectangle into the nine this inset describes.
Used by (20)
- DrawCommandVixen.Ui
- DrawContextVixen.Ui
- ImageVixen.Ui.Controls
- NineSliceImageTestsVixen.Ui.Tests
- NineSliceTestsVixen.Core.Mathematics.Tests
- SpriteVixen.Rendering
- SpriteGeometryVixen.Rendering
- SpriteRenderFeatureTestsVixen.Rendering.Tests
- SpriteSheetVixen.Rendering
- SpriteTestsVixen.Rendering.Tests
- TypeRegistrationVixen.Core.Mathematics
- UiGeometryBuilderVixen.Ui
- Vixen_Core_Mathematics_NineSliceSerializerVixen.Core.Mathematics
- Vixen_Rendering_Sprites_SpriteSerializerVixen.Rendering
- SpriteDocumentTestsVixen.Editor.AssetEditors.Tests
- SpriteRectVixen.Editor.Assets
- SpriteSliceOptionsVixen.Editor.Assets
- SpriteSlicerVixen.Editor.Assets
- SpriteSlicerTestsVixen.Editor.Assets.Tests
- TextureImporterTestsVixen.Editor.Assets.Tests