TurkeyMan / color

Development for std.color
14 stars 6 forks source link

Will there be support for other colorspaces? (munsell) #1

Open BlackEdder opened 8 years ago

BlackEdder commented 8 years ago

More a question than an issue, but I was wondering if you are likely to add support for munsell (and Lab) colourspaces or if that is out of the scope of the library?

TurkeyMan commented 8 years ago

Ah I haven't pushed to this repo in a while. I'm mainly working in the branch in my phobos fork. I'll update this shortly, there has been more work since my last push.

I hadn't planned initial support for Munsell (is it useful to you?), but there will definitely be Lab. I didn't want to go nuts with the first release, I was planning: RGB, HSx, XYZ/xyY, Lab. Maybe YCbCr (and friends). Munsell is easy enough to do though if it's useful; blend primitives are defined by other colourspaces already in the list above.

I'm working on API for doing high-level operations like blends and stuff at the moment, and thinking about array/batch processing API's.

BlackEdder commented 8 years ago

I was mainly suggesting munsell, because it is suggested by ggplot2 as a good way to get nice looking color palettes.

Their documentation mentions: "Generally, for continuous colour scales you want to keep hue constant, but vary chroma and luminance. The munsell package makes this easy to do using the Munsell colour system."

There might well be other colourspaces that are also suitable for this task (Lab?).

Is the plan to add helpers for "linear" colour scales as well?

About the phobos fork. Is it possible for me to use your more up to date work from dub? Or would that require using your whole phobos fork? Would be great if you could provide an up to date dub package.

TurkeyMan commented 8 years ago

There might well be other colourspaces that are also suitable for this task (Lab?).

Lab is generally considered to have superseded Munsell in it's original intent (more perceptually uniform), but Munsell is still useful in some cases since it's a HSV style (polar) colourspace rather than a vector space. You're right, I'll add Munsell as a compliment to HSx, just as Lab is more of a compliment to RGB. It's useful.

Their documentation mentions: "Generally, for continuous colour scales you want to keep hue constant, but vary chroma and luminance. The munsell package makes this easy to do using the Munsell colour system."

If you want a polar colourspace with reasonable perceptual distribution (like Munsell), you can use HCY' in the meantime which I've already done and I'll push it in an hour or so. HCY' differs from Munsell in that Hue is not perceptually uniform like Munsell, but if you're not lerping the Hue (which it sounds like you're saying; Hue is constant, you're lerping the other channels?), then HCY's Chroma and Luma should be quite similar to Munsell, and those 2 channels lerp and blend well perceptually.

Is the plan to add helpers for "linear" colour scales as well?

Linear RGB colourspaces are already supported. Other colourspaces are always linear.

About the phobos fork. Is it possible for me to use your more up to date work from dub? Or would that require using your whole phobos fork? Would be great if you could provide an up to date dub package.

I'll update this repo tonight with my latest work, but I think the only new feature I've done that'll be interesting to you is the HCY' colourspace, and improved colourspace conversion. I'll prioritise those features for you (Munsell/Lab) if you're actively using this library.

BlackEdder commented 8 years ago

I'll update this repo tonight with my latest work, but I think the only new feature I've done that'll be interesting to you is the HCY' colourspace, and improved colourspace conversion. I'll prioritise those features for you (Munsell/Lab) if you're actively using this library.

It sounds like HCY' should fit my use case reasonably well, so if that is supported (and its conversion to RGB) then that would fit my needs.

(I just noticed that ggplot itself actually uses Lab internally http://docs.ggplot2.org/0.9.3.1/scale_gradient.html)

TurkeyMan commented 8 years ago

On a side note, I'm surprised a plot library really cares particularly about colourspaces... why is it so important?

BlackEdder commented 8 years ago

On a side note, I'm surprised a plot library really cares particularly about colourspaces... why is it so important?

Mainly because you want to easily map values to nice looking colours. This mostly comes up when you want to map 3D to 2D. Colours can then be used to represent the 3rd dimension (height).

Choosing the correct colourspace makes it easy to define a linear (natural looking) path from one color to another. The value (height) represents how far along that path you are.

TurkeyMan commented 8 years ago

kk, pushed some updates. Have a go at that. I haven't tested latest much, so let me know if any problems.