Device-Independent input + Rendering library for .NET. Provides the shared foundation for both GPU (SDL3 + Vulkan) and terminal (Console) applications.
PointInt— 2D integer pointRectInt— 2D integer rectangle (upper-left + lower-right)RectF32— 2D float rectangle (x, y, width, height) for pixel-based layoutRGBAColor32— 32-bit RGBA color with Lerp, WithAlpha, LuminanceTextAlign— Near/Center/Far alignment enumRenderer<TSurface>— Abstract renderer: FillRectangle, DrawRectangle, FillEllipse, DrawText, MeasureTextGlyphBitmap— Raw RGBA glyph bitmap with bearing/advance infoFreeTypeGlyphRasterizer— FreeType2-based glyph rasterizer with COLRv1 color emoji support
InputKey— Platform-agnostic key codes (letters, digits, function keys, navigation, symbols)InputModifier— Modifier flags (Shift, Ctrl, Alt)IWidget— Shared interface withHandleKeyDownandHandleMouseWheelfor both pixel and terminal widgets
Platform bridges (in downstream packages):
SdlVulkan.RendererprovidesSdlInputMapping(SDL3 Scancode → InputKey)Console.LibprovidesConsoleInputMapping(ConsoleKey → InputKey)
IPixelWidget— Extends IWidget with pixel-coordinate hit testing and click dispatchPixelWidgetBase<TSurface>— Base class for pixel widgets: clickable regions, text input, buttons, drawing helpersPixelLayout+PixelDockStyle— Dock-based layout engine (Top/Bottom/Left/Right/Fill)ClickableRegion— Registered during render, walked in reverse for hit testingHitResult— Open discriminated union: TextInputHit, ButtonHit, ListItemHit, SlotHit<T>, SliderHit
TextInputState— Single-line text input state machine with cursor, selection, undoTextInputKey— Abstract key actions (Backspace, Delete, Left, Right, Home, End, Enter, Escape)TextInputRenderer— Renders text input using anyRenderer<T>(blinking cursor, selection highlight)- Callbacks:
OnCommit(async),OnCancel,OnTextChanged,OnKeyOverride
BackgroundTaskTracker— Collects background tasks, checks completions per frame, logs errors viaILogger. CallProcessCompletions()each frame,DrainAsync()at shutdown.
using DIR.Lib;
// Rendering
renderer.FillRectangle(rect, new RGBAColor32(0x30, 0x50, 0x90, 0xff));
renderer.DrawText("Hello", fontPath, 14f, white, layout);
// Input handling (SDL3 example)
var key = evt.Key.Scancode.ToInputKey; // via SdlVulkan.Renderer
var mod = evt.Key.Mod.ToInputModifier;
widget.HandleKeyDown(key, mod);
// Pixel layout
var layout = new PixelLayout(contentRect);
var header = layout.Dock(PixelDockStyle.Top, 28f);
var sidebar = layout.Dock(PixelDockStyle.Left, 200f);
var content = layout.Fill();
// Background tasks
tracker.Run(async () => await SaveAsync(), "Save profile");
if (tracker.ProcessCompletions(logger)) needsRedraw = true;- SharpAstro.FreeTypeBindings — FreeType2 native bindings
- Microsoft.Extensions.Logging.Abstractions — ILogger interface for BackgroundTaskTracker
MIT