Zig-color color space library

This is a small library (wip) for using and manipulating color spaces. The plan is to support RGBA, CMYK and HSL, conversion between all spaces, usage of generic types so that any width float or unsigned integer can be used for storage, etc.

I started this because I realized that I was writing the same code for handling RGBA, converting it to and from hexadecimal strings and integer to float conversions over and over again. I started expanding it when I realized that we probably need something like this and it wouldn’t be too difficult.

Right now, RGBA is the most supported color space, and conversion from RGBA to CMYK just landed.


Added CMYK toRGBA toHex and fromHex methods, as well as toString methods for both RGBA and CMYK. The toString and toHex methods also have toHexZ variants which return the array null terminated.

Just need to finish HSL, and then work on parsing into the structs from strings.

1 Like

“add to your project” section for zigmod would be

  - src: git https://codeberg.org/jeang3nie/zig-color

Thanks. I spent the last several days down with a virus, but I’m up and about today. I’ll have some changes to push later and will add this to the README.

Changes pushed. I fixed a few issues with HSL, and added a conversion method to go from RGBA to HSL.

@nektro I also annotated the README file.

1 Like