Live data from Hacker News

BackgroundCheck

kennethcachia.com

11–20 of 30 posts

Re: BackgroundCheck

#11
Hehe, nice. I tried to put the small dot on the big one, both had the same dark hue, so I guess it works only on background, not on other placed elements, right?

Re: BackgroundCheck

#14
I would do it in RGB space. Run kmeans to get a set of Voronoi cell centroids, 5-6 should be good. Then take the Delaunay triangulation of that and pick a color midpoint between Voronoi neighbors that maximizes the distance sum from all the Voronoi generator points.

[1] http://en.wikipedia.org/wiki/File:Delaunay_Voronoi.svg

[2] http://people.sc.fsu.edu/~jburkardt/isu/reu_2001/voronoi_pap...

Re: BackgroundCheck

#17
post #5

This is a nice step, but not good enough for practical use. Put the text half on the black lamp, half off, and you get 1/2 invisible text. While interesting, it's not reliably accurate enough to use in any sort of automated fashion.

I disagree although my first thought was exactly the same; how do you solve the problem of half of some text being on a dark background and the other half on a lighter area.

I see three solutions to the problem.

The first is not so elegant. If you have text then you wrap each letter in a span tag and apply the JS to each span. Very ugly, not practical, scalable, etc. but it works. If you've got dynamic text coming from a backend then just forget it. This solution is only viable for static content and even then it's not great.

You could implement this as instructed and then just give the text an outline of the exact opposite color. Chances are your text will not equally overlap both a light and dark background so this wouldn't look too bad at all.

The third solution is to just know your backgrounds very well and choose element placement very carefully so that no matter what background you have your text ends up in an all light or all dark part of it. If I had Medium style app where users get to choose the background image of an element that gets text laid over it this is what I might be okay with doing and accepting that not all the background images will lend themselves well to this technique.

Or... There's a fourth way that I've actually had to consider in one of my projects. Until I saw this post I didn't have the final piece of the puzzle but now I do. I would take the ability to dynamically change the text color based on a background and add to it a translucent background to the text with some padding to make it a blocky thing - kind of like how ios7 handles it in notification center.

The idea is that if you have an element over a mostly light background you give that text itself a light background with about 70% - 80% opacity and the text color dark. This way you're covered even if part of the text is on top of some random dark part of the image background. It's the same idea as using a text outline except its more cross-browser compatible and I personally think it looks better.

But like I said, if you're not in control of the text and/or background there probably isn't going to be a bullet proof solution and you'll have to accept trade offs but if you are in total control then there's no reason you can't mitigate these issues completely.

Re: BackgroundCheck

#18
So, I'd propose a modification to handle text:

Color is part of the battle, but the real killer is having things of roughly the same frequency behind the text--that is to say, having fine lines and detail of about the same resolution as the letters of the text. That seems to be what makes it harder to pick out words.

So, if you could maybe do a 2D FFT or DCT on the area the text would take up, and if the frequencies you find are beyond a certain threshold, add a background color for the text, maybe opacity based on how close in frequency or harmonics the image is to the text.

Re: BackgroundCheck

#20

I'll start by saying that I think this is pretty cool and clever, and pretty useful for text. It works great on Safari. I should however add, that while moving the elements over the picture, I didn't once lose sight of my cursor, as it is black with a white outline, which seems to be a much simpler solution to the problem.

Agree 100%, especially when it comes to the text elements.

Even if they expanded the system such that it were capable of automatically creating spans in the text to adjust from white to black depending upon the background color under specific letters, having the text switch from black to white and back again along with the background would look horrible and would be terrible for reading. But using high contrast outlines works fine on just about anything, which is why that is the go-to for all "meme" photos (Impact white with black outline). While I would suggest avoiding Impact unless you are actually trying to make a "meme" association, this sort of high contrast outlined text is still by far the best way to handle text over images that may themselves be high contrast.

Sadly, true text outline support is inexplicably very bad among browsers, at least as of the last time I checked, though in CSS3-capable browsers you can cheese outlines using textshadow.

Post reply on HN