Random Colors and Text Readability

Mar 8, 2012 at 6:06pm

Random Colors and Text Readability

I’m working with a patch with a UI that will smoothly change the background color of the patcher and all text objects on it (message and comment boxes) upon a certain key press (RGB values chosen randomly). The text of all of these objects remains black. However, sometime the random value chosen is too dark to read the black text against it. I’m trying to select the “complementary” choices to change the text color (by using the [!- 1.] object) but sometimes the colors chosen are very similar as well. It comes down to me not knowing anything about color theory, hah!

I suppose I want it to either display a color for the text that is ALWAYS readable and complementary to the background color, or flip it from white to black and vice versa once it crosses a threshold of darkness.

I’ve tried to look up some equations to calculate readability but can’t really isolate the variables that are too close or too far apart in value when I try to see what’s going on between the too-close colors.

Thanks. You all rock!

– Pasted Max Patch, click to expand. –
#62236
Mar 8, 2012 at 9:15pm

what’s the complementary colour of grey?

What I think you need to do for a second is have a good long think about specification here ;)

Also, think about if you *really* want a completely random colour in there. I find that settling on a specific saturation helps, and then you can drastically offset light, and move around in the hues.

What I’m saying is that it might help to start by looking at HSV->RGB conversion. Something max does quite readily, too.

#224830
Mar 9, 2012 at 5:10am

+1 on that, using truly random colors tends to look more gaudy than cool. But if you stick to a small hue range and modify the saturation and brightness, you can still get variation (and readability) and it looks much more elegant.

use hsl message to [swatch] for starters!

#224831
Mar 9, 2012 at 9:06pm

Thanks SeeJay for the excellent advice.

I negotiated the difference by using a drunk object controlling hue values (with constant saturation and luminosity), so the background can move across a wide but fairly muted spectrum. The step size is 20 per bang so it’s noticeable without being obnoxious or ever making the text unreadable.

I’m glad that bgcolor can take HSL values too!

– Pasted Max Patch, click to expand. –
#224832

You must be logged in to reply to this topic.