ktsu.ImGui.Color
3.80.0
Prefix Reserved
dotnet add package ktsu.ImGui.Color --version 3.80.0
NuGet\Install-Package ktsu.ImGui.Color -Version 3.80.0
<PackageReference Include="ktsu.ImGui.Color" Version="3.80.0" />
<PackageVersion Include="ktsu.ImGui.Color" Version="3.80.0" />
<PackageReference Include="ktsu.ImGui.Color" />
paket add ktsu.ImGui.Color --version 3.80.0
#r "nuget: ktsu.ImGui.Color, 3.80.0"
#:package ktsu.ImGui.Color@3.80.0
#addin nuget:?package=ktsu.ImGui.Color&version=3.80.0
#tool nuget:?package=ktsu.ImGui.Color&version=3.80.0
ktsu.ImGui.Color
ImGui.Color is the bridge between ktsu.Semantics.Color and Dear ImGui. Colors are held as the semantic Color (linear) and Srgb types and converted only at the ImGui seam, so color math happens in a space where it is meaningful and ImGui still receives the gamma-encoded values it expects. It is a standalone package with no dependency on ktsu.ImGui.App, so it can be dropped into any Hexa.NET.ImGui application.
Features
- Conversions at the seam only:
Color↔ImColor,ImGuiVector4and packedImU32, with the sRGB/linear boundary handled for you - Direct sRGB path:
Srgbvalues pack straight through with no linear round-trip, for colors authored as sRGB (fixed UI colors, overlays, HSL-derived hues) - A strong vector type:
ImGuiVector4states that a vector is sRGB-encoded and ImGui-ready, and widens implicitly toSystem.Numerics.Vector4 - ImColor operations: lighten/darken, saturate/desaturate, hue offset, grayscale, invert, alpha
- Accessibility analysis: relative luminance, WCAG contrast ratio, perceptual distance
- Contrast heuristics:
MostReadableTextColorandAdjustForSufficientContrastpick text that stays legible on a given background
All color math delegates to ktsu.Semantics.Color; this package only adapts it.
Installation
Package Manager Console
Install-Package ktsu.ImGui.Color
.NET CLI
dotnet add package ktsu.ImGui.Color
Package Reference
<PackageReference Include="ktsu.ImGui.Color" Version="x.y.z" />
Usage Examples
Basic Example
using ktsu.ImGui.Color;
using ktsu.Semantics.Color;
using Hexa.NET.ImGui;
Color accent = Color.FromHex("#ff6b6b");
ImGui.PushStyleColor(ImGuiCol.Button, accent.ToImGuiVector4());
ImGui.Button("Danger");
ImGui.PopStyleColor();
// Drawing straight into a draw list wants a packed color. ToImGuiU32Styled applies the style
// alpha, so the fill dims inside BeginDisabled like everything around it.
ImGui.GetWindowDrawList().AddRectFilled(min, max, accent.ToImGuiU32Styled());
Colors authored as sRGB
Srgb carries gamma-encoded channels, so it packs directly with no linear round-trip. Alpha is supplied at the conversion, since Srgb holds only RGB.
uint shadow = new Srgb(0.0, 0.0, 0.0).ToImGuiU32(alpha: 0.3f);
ImGui.GetWindowDrawList().AddRectFilled(min, max, shadow);
Readable text on any background
Span<Vector4> style = ImGui.GetStyle().Colors;
ImColor background = new() { Value = style[(int)ImGuiCol.WindowBg] };
ImColor label = background.MostReadableTextColor();
// Or keep an intended color and only push it as far as it needs to go
ImColor adjusted = background.AdjustForSufficientContrast(brandColor);
Adjusting a color
ImColor hovered = baseColor.LightenBy(0.1f);
ImColor pressed = baseColor.DarkenBy(0.1f);
ImColor muted = baseColor.DesaturateBy(0.4f);
ImColor disabled = baseColor.WithAlpha(0.4f);
API Reference
ColorImGuiExtensions
Conversions between the semantic linear Color and ImGui's types. Every conversion emits or accepts gamma-encoded sRGB.
| Name | Return Type | Description |
|---|---|---|
ToImColor(this Color) |
ImColor |
Converts to an ImGui color |
FromImColor(this ImColor) |
Color |
Reads an ImGui color back, interpreting its channels as sRGB |
ToImGuiVector4(this Color) |
ImGuiVector4 |
Converts to the strong sRGB vector |
FromImGuiVector4(ImGuiVector4) / FromImGuiVector4(Vector4) |
Color |
Reads a vector back as sRGB |
ToImGuiU32(this Color) |
uint |
Packs to ImU32 (0xAABBGGRR), matching ImGui.ColorConvertFloat4ToU32. A pure pack — the global style alpha is not applied |
ToImGuiU32Styled(this Color) |
uint |
Packs for drawing, applying the global style alpha like ImGui.GetColorU32, so a fill dims inside a disabled or faded scope. Use it wherever a Color feeds a draw list |
ToImGuiU32(this ImColor) |
uint |
Packs an ImColor, applying the global style alpha exactly like ImGui.GetColorU32 |
SrgbImGuiExtensions
Direct conversions from a gamma-encoded Srgb, with no linear round-trip. Each takes an optional alpha (default opaque).
| Name | Return Type | Description |
|---|---|---|
ToImColor(this Srgb, float) |
ImColor |
Packs the sRGB channels straight through |
ToImGuiVector4(this Srgb, float) |
ImGuiVector4 |
The strong sRGB vector |
ToImGuiU32(this Srgb, float) |
uint |
Packed ImU32, applying the global style alpha like ImGui.GetColorU32 |
ImColorExtensions
Operations on an ImColor, all delegating to ktsu.Semantics.Color.
| Group | Members |
|---|---|
| Adjustment | WithSaturation, SaturateBy, DesaturateBy, MultiplySaturation, WithLightness, LightenBy, DarkenBy, MultiplyLightness, OffsetHue, ToGrayscale, Invert, WithAlpha |
| Analysis | GetRelativeLuminance, GetContrastRatioOver, GetColorDistance |
| Contrast | MostReadableTextColor, AdjustForSufficientContrast |
| Conversion | ToSrgb, ToHsl, ToImGuiVector4 |
ImGuiVector4
A readonly record struct of X, Y, Z, W stating that the vector is sRGB-encoded and ImGui-ready. Widens implicitly to System.Numerics.Vector4 (or explicitly via ToVector4()), and offers One and Zero.
There is no ImColor factory class in this package: construct colors as Color or Srgb and convert.
Acknowledgments
- Dear ImGui - The immediate mode GUI library these colors are handed to
- Hexa.NET.ImGui - The .NET bindings for Dear ImGui that define
ImColor - ktsu.Semantics - The
Color,Srgb,Hsland Oklab types, and all of the color math behind this adapter
Contributing
Contributions are welcome! For feature requests, bug reports, or questions, please open an issue on the GitHub repository. If you would like to contribute code, please open a pull request with your changes.
License
ImGui.Color is licensed under the MIT License. See LICENSE.md for more information.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Hexa.NET.ImGui (>= 2.2.9)
- ktsu.Semantics.Color (>= 5.12.1)
-
net8.0
- Hexa.NET.ImGui (>= 2.2.9)
- ktsu.Semantics.Color (>= 5.12.1)
-
net9.0
- Hexa.NET.ImGui (>= 2.2.9)
- ktsu.Semantics.Color (>= 5.12.1)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on ktsu.ImGui.Color:
| Package | Downloads |
|---|---|
|
ktsu.ImGui.Styler
A powerful styling library for ImGui.NET interfaces featuring 50+ built-in themes (Catppuccin, Tokyo Night, Gruvbox, Dracula, Nord, and more), interactive theme browser, scoped styling system for colors and style variables, advanced color manipulation with hex support and accessibility features, automatic content alignment and centering, semantic text colors, button alignment, and indentation utilities. |
|
|
ktsu.ImGui.Widgets
A comprehensive library of custom widgets and UI components for ImGui.NET, featuring radial progress bars with countdown/count-up timers, tabbed interfaces with drag-and-drop support, type-safe combo boxes, resizable divider containers, powerful search boxes with fuzzy matching, icons with event handling, flexible grid layouts, and scoped utilities for IDs and disabling elements. |
|
|
ktsu.ImGui.Markdown
Renders CommonMark markdown directly inside Dear ImGui, parsed with Markdig and extended with pipe tables, task lists and autolinks. Headings scale from the live font size, so DPI and accessibility scaling are respected automatically; links are clickable, local images resolve through a callback, and code blocks can be handed to a renderer hook that ktsu.ImGui.SyntaxHighlighting plugs into. Offers a cached static entry point and a document instance that parses once for hot render paths, with no dependency on ktsu.ImGui.App. |
|
|
ktsu.ImGui.SyntaxHighlighting
Renders syntax-highlighted source code inside Dear ImGui. Ships a data-driven tokenizer with definitions for fifteen languages, theme-aware palettes that follow the host application's light or dark theme, an optional line-number gutter, and cached tokenization for immediate-mode render loops. Layered on ktsu.ImGui.Color only, with no dependency on ktsu.ImGui.App, so it drops into any Hexa.NET.ImGui application — including as the code-block renderer for ktsu.ImGui.Markdown. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.80.0 | 385 | 11/10/2026 |
| 3.79.1-pre.3 | 95 | 10/28/2026 |
| 3.79.1-pre.2 | 91 | 10/27/2026 |
| 3.79.1-pre.1 | 92 | 10/26/2026 |
| 3.79.0 | 649 | 10/26/2026 |
| 3.78.3 | 243 | 10/25/2026 |
| 3.78.2 | 340 | 10/24/2026 |
| 3.78.1 | 217 | 10/24/2026 |
| 3.78.0 | 258 | 10/22/2026 |
| 3.77.3 | 260 | 10/21/2026 |
| 3.77.2 | 240 | 10/21/2026 |
| 3.77.1 | 238 | 10/21/2026 |
| 3.77.0 | 231 | 10/20/2026 |
| 3.76.1 | 248 | 10/20/2026 |
| 3.76.0 | 223 | 10/20/2026 |
| 3.75.4 | 868 | 10/19/2026 |
| 3.75.3 | 320 | 10/18/2026 |
| 3.75.2 | 285 | 10/17/2026 |
| 3.75.2-pre.1 | 101 | 10/16/2026 |
| 3.75.1 | 374 | 10/14/2026 |
## v3.80.0 (minor)
Changes since v3.79.0:
- Add a SessionStart hook for Claude Code cloud sessions (#713) (matt-edmondson)
- Use Path.Join for the temporary PNG path in PngEncoderTests (Claude)
- [minor] Move image decoding into ktsu.Imaging (Claude)
- Read C++ raw string literals as one string [minor] (#742) (matt-edmondson)
- Read HTML script and style bodies as text up to their closing tag [minor] (#741) (matt-edmondson)
- Keep a backslashed quote inside a Python raw string [minor] (#740) (matt-edmondson)