Adaptive Backgrounds – A jQuery plugin for extracting dominant colors
briangonzalez.github.io
briangonzalez.github.io
It would be nice if you could specify an offset along the color wheel to select complimentary or analogous colors.
The default of selecting the dominant color removes all contrast between the image and the background which seems like a rarely desired behavior.
Secondly, I don't like it. In the general case, this is not something that should be left to the client to calculate - whenever you are serving the image, the server ought to know what the dominant colour is. Why make the client calculate this every time the image is displayed?
This is a case where JavaScript harms the user: a JavaScript/jQuery solution to this has significant potential problems: there are numerous cases where it will break, some of which are identified in the other comments.
I agree with the server handling of this if the server is providing the image but I could imagine HTML5 web apps making use of color analysis before the image ever gets sent to the server. JS isn't going away regardless of how much we close our eyes and pretend it's not there.
I think we are in violent agreement ;)
The end product was never realized in that form but our solution included using a 2d canvas also and doing a count of color segments.
Throw a copy of your javascript in the actual gh-pages branch.
demo: http://o-0.me/RgbQuant/
The author of this seems not to have paid attention to that, which is particularly silly since the page is hosted on GitHub pages, and the assets can (and should) be hosted there as well.
In any case, I've now moved the library to also be hosted on Github pages.
It is actually quite cool, I tried similar thing (albeit a trivial approach) with css only: http://cssdesk.com/VYN67
Try changing image url in source to see different effect.
Any particular reason for the jQuery dependency? I can't see any good reason for tying this to jQuery, since I would expect it only to use jQuery for selecting a DOM element, which is more than easy enough to do without jQuery.
A dependency on underscore strikes me as usually being more reasonable if you use more than 1-2 functions from the library. I regularly use many functions from underscore when I include it in a project since it includes many utility functions for functional programming that are missing from the basic prototypes in JavaScript.
Perhaps, a HN DoS?