2

I'm looking to generate random "similar" colors using jquery.

It is my understanding that the best way to approach this is using HSL or HSV, according to this question.

The issue is I can't seem to figure out how to either…

  1. Use HSL or HSV with jquery; or
  2. Convert HSL or HSV to RBG via jquery

I found this color library, but i'd like to avoid plugins if at all possible. Any idea's?

Community
  • 1
  • 1
Derek Adair
  • 21,846
  • 31
  • 97
  • 134

2 Answers2

2

Best idea ever: DIY :)

Write a simple conversion function. It'd be 4 lines of math

Look here for start: http://en.wikipedia.org/wiki/HSL_and_HSV

And use colors in CSS as follows

color: rgb(255, 255, 255);

And cut it up with string functions.

Still not sure what to do? Ask for details in comments ;)

naugtur
  • 16,827
  • 5
  • 70
  • 113
  • Yea, that's what I figured. thanks. I might come back for more help =) – Derek Adair Feb 08 '10 at 17:16
  • 2
    check out these: http://www.csgnetwork.com/csgcolorsel4.html http://snipplr.com/view/14590/hsv-to-rgb/ The code in the second thing seems a bit too complicated IMHO, It might be doing something extra :P add a comment when You use any of this. I might be wanting to repeat Your work some day :) – naugtur Feb 08 '10 at 17:23
  • @naugtur From a quick look at the code in each of your links, it appears that they basically work the same way. But they seem to work! Thanks for the links. – Matt May 08 '14 at 03:11
0

See here, this looks like it would do everything: https://www.adaptavist.com/display/jQuery/Colour+Library

Luke H
  • 3,125
  • 27
  • 31