Skip to content

Implementation of Rgba8 type#41

Merged
raphlinus merged 2 commits intomainfrom
rgba8
Nov 14, 2024
Merged

Implementation of Rgba8 type#41
raphlinus merged 2 commits intomainfrom
rgba8

Conversation

@raphlinus
Copy link
Contributor

Adds Rgba8 type and some conversions and formatting.

This PR also changes the serialization of srgb to use the color function. If legacy RGB serialization is desired, the client can convert to Rgba8 first.

Closes #24.

Adds Rgba8 type and some conversions and formatting.

This PR also changes the serialization of srgb to use the color function. If legacy RGB serialization is desired, the client can convert to Rgba8 first.

Closes #24.
@raphlinus
Copy link
Contributor Author

I'm pushing this partly for discussion. There's not a huge amount of functionality attached to the new type - maybe that's a good thing, we should encourage all actual manipulation (including parsing) to happen in with the f32-based types.

Copy link
Collaborator

@waywardmonkeys waywardmonkeys left a comment

Choose a reason for hiding this comment

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

I don't even see anything worth discussing offhand. Seems reasonable.

I guess the one thing might be if we wanted to have an Rgb8 without alpha, but I don't think that's necessary and if it was, experiment with it in the codebase that needs it.

The one thing that I see that might be missing is a to_premul_u32 method like peniko::Color has (and that Vello uses). But Vello can also just do that math on its own...

@tomcur
Copy link
Member

tomcur commented Nov 14, 2024

This PR also changes the serialization of srgb to use the color function. If legacy RGB serialization is desired, the client can convert to Rgba8 first.

I believe that follows the spec, which does that unless the color was constructed directly from a named color or from a named color space (if I'm reading this correctly – note it excludes the color function). The named color space functions that map to RGB clamp during parse-time according to the spec, so can be represented as legacy RGB when serialized.

e.g.,

rgba(50, 75, 100, 0.8) serializes to rgba(50, 75, 100, 0.8)
color(srgb 0.1 0.2 0.3 / 0.8) serializes to color(srgb 0.1 0.2 0.3 / 0.8)

In my experimental draft #39 I'm trying to find a nice implementation according to spec.

@raphlinus
Copy link
Contributor Author

Great, I'll merge this and then we can consider further refinements separately.

@raphlinus raphlinus added this pull request to the merge queue Nov 14, 2024
Merged via the queue into main with commit fc24aaf Nov 14, 2024
@raphlinus raphlinus deleted the rgba8 branch November 14, 2024 20:20
@waywardmonkeys waywardmonkeys added this to the Initial Release milestone Nov 15, 2024
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.

Rgba8

3 participants