Skip to content

Comments

Better color API#6197

Open
vgskye wants to merge 13 commits intospace-wizards:masterfrom
vgskye:better-colors
Open

Better color API#6197
vgskye wants to merge 13 commits intospace-wizards:masterfrom
vgskye:better-colors

Conversation

@vgskye
Copy link
Contributor

@vgskye vgskye commented Sep 15, 2025

Currently the colorspace-related APIs in Color is a mess, putting Linear sRGB values in Color and all other colorspaces just using Vector4 without any safeguards against confusing, say, HSL for HSV. This PR adds the Colors namespace, which holds actually typed color classes with methods for converting between them as appropriate.

Opened as Draft because I want to add more features(mainly Oklab gamut clipping) and have colorspace parity with Color, and then add deprecations to the existing Color colorspace API while making them be wrappers over the Colors API.

@vgskye vgskye changed the title Better color API(wip) Better color API Sep 16, 2025
@vgskye vgskye marked this pull request as ready for review September 16, 2025 10:14
namespace Robust.Shared.Maths.Colors;

/// <summary>
/// Represents a color with alpha in the sYCC colorspace.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of including sycc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parity with existing Color API, mostly.

@vgskye
Copy link
Contributor Author

vgskye commented Feb 15, 2026

I have now added ToColor() methods to all Colors API structs and ToXXX() methods to Color so it's much more ergonomic to use for the common case of "convert to some other colorspace, do work, convert back to sRGB". The Color methods also use the same method names as the old API, just as instance methods instead of static.

@ZeWaka
Copy link

ZeWaka commented Feb 16, 2026

👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants