Hacker News new | ask | show | jobs
by djoldman 293 days ago
But what really is a "color gradient"?

Isn't it any continuous function that starts at a specified color and ends at another specified color?

How then does one say that any gradient is good or bad?

Isn't the problem you are highlighting guaranteed to exist for any colorspace that defines colors outside of human perception?

2 comments

A good gradient is one that takes a perceptually uniform, and typically perceptually shortest, path. The OKLCH gradient isn't perceptual uniform and appears to take unnecessary detours through other hues.
One could also argue that the detour through other hues is necessary in this case to avoid going through grey.
Gray is arguably just another color, it’s not clear why you’d want to avoid it. How is going via red and yellow better than going via gray? Varying hue is often perceived as a larger change than varying saturation or lightness. A path going through several distinct hues is visually less uniform than one going through gray once.
Is gray perceived as "just another color" or where all colors go when desaturated? I assumed the latter, which would explain why to avoid it if one isn't playing with saturation.
Think of fashion, of smartphone colors, pen and pencil colors and the like. Gray, white, black, are just color choices among all the available colors. A gray T-shirt isn’t a desaturated colored T-shirt. It’s its own color.
Color is weird like. Gray is “all the visible spectrum in equal proportions”, which is white… just less white than the whitest thing visible but more white than the darkest (blackest) thing visible.

It’s a “color” because it’s useful to describe such a thing. If you had monitor entirely filled with 50% white you’d call it white. Only by comparing it to something brighter do you call it gray. Brown is the same thing. In a dark room if you looked at a monitor filled with red and green pixels you’d call it orange. Only when you start adding in clues like whites and brighter colors would you call it brown.

Anyway, yes grey is a color. But it is not quite the same as other colors. Other colors occupy only parts of the visible electromagnetic spectrum. Whites are the whole thing.

There is actually several very good technology connections videos about this stuff. Color is very cool!

Oh, I understand what you say. But in color spaces, isn't gray the "sink" towards which desaturated colors shift? This would make it a location to avoid (unless you're purposefully desaturating).
A grey shirt is a desaturated shirt. You cannot resaturate grey.

I think if you buy a tie-dye shirt or phone case and it comes out half grey, despite it being a valid color, most folks will be disappointed.

Let's say you continuously change wavelength of a laser from blue (~480nm) to red (~630nm), you are going through green, not through gray. If in your use case going through gray makes sense, that's ok, there may be many paths from one color to another.
In general people don't really think of color in terms of the spectral progression (or the hue wheel), and I don't think that most people intuitively expect a gradient between two colors to pass through another "unrelated" primary or secondary color. The point is somewhat moot though, given that such gradients (like yellow to blue or red to green) are very unnatural anyway.
I disagree somewhat. Color mixing just isn't particularly intuitive. It's not the most intuitive to get a third hue, but that doesn't justify grey (which has an undefined hue). I do think most people are quite comfortable with the fact that between blue and yellow exists green, but is it a saturated green or a desaturated green? Additive and subtractive color mixing behave very differently here.
It's funny and a bit sad because we just went througha decades-long effort to migrate away from jet/rainbow gradients to vik/batlow/bi-hue gradients, and now rainbow is forcing its way back.

https://theconversation.com/how-rainbow-colour-maps-can-dist...

https://www.poynter.org/archive/2013/why-rainbow-colors-aren...

Honestly I suspect this is largely a non issue. I have never made a gradient that goes through more than 2 different color (by some vague measure of different) without adding an additional stop. If I wanted to go through yellow and green to get to blue, I would add a stop at yellow and another at green, and I suspect most developers would do the same.
Shine a red and a green light near each other on a wall — what does the transition look like?
There's no transition, this is color mixing, or overlay in case of light.
It depends on how you think about your spread. If, as someone else said, you're trying to represent a tunable laser going from red to blue, going through gray is completely wrong. That is not what a laser will do, ever. It will always be a fully saturated color.

So, depending on what you're doing, you want different things. You may want to view your color space as an RGB cube, and go through gray. Or you may want to view your color space as something more like HLS or OKLCH, and not go through gray.

Gray is arguably not just another color; I don't know about English but in German you have 'bunte' and 'unbunte' colors; 'unbunte' colors are white, black, and the grays in between
It's an ugly color. Saturation makes stuff pop; this is often desirable. This is why I think it's important to have both polar (OKLCH) and rectilinear (Oklab) gradients.
Let's say neither going through gray nor through two different hues looks particularly great. It's pick your poison.
> Gray is arguably just another color

Only if you're working with additive color.

With substractive, grey is just a darker (or dimmer) white.

Interesting. In nature, I suppose I am most aware of a gradient from a saturated azure sky above to a much whiter sky on the horizon. This would seem to be a trivial saturation gradient.

For a spot color (from a gel covering a light) the light diffuses further from the center of the projected light — two spot colors (with different gels) then, next to each other, would give a kind of gradient from one color to the next as you walk a line from the center of one light to the other.

I wonder what the closest analog to this is algorithmically?

I guess where I am going with this is: is there precedent in nature as to how gradients are supposed to work (and therefore an analog which we should try to model) or are we going strictly on how the human eye perceives color and what algorithm we think "looks" right?