|RGB||rgb(19, 104, 4)|
|RGBA||rgba(19, 104, 4, 1)|
|CMYK||0.817, 0.000, 0.962, 0.592|
|HSL||111.000, 0.926, 0.212, 1.000|
|HSV||111.000, 0.962, 0.408|
|LAB||37.927, -42.140, 42.238|
|LCH||37.927, 59.664, 134.934|
|HCL||134.934, 59.664, 37.927|
|HSI||112.006, 0.906, 0.166|
There are a variety of reasons for generating random colors. One may want to generate colorful backgrounds or foregrounds, they might be looking for fun color palettes in which to design their next project, and one might be playing around with various styles of geometric art and wants some more interesting shapes.
For these reasons I have written a small tool that generates random colors. This tool is easy to use and doesn't require downloading any additional software.
To use the tool, simply click on the big "Generate" button repeatedly, until you find a color you like.
Once you like a color, select and copy its value from the column on the right, in the color space of your choice (currently supports Hex, RGB, RGBA, CMYK, HSL, HSV, LAB and more.)
To generate a random RGB color, first generate a random number between 0 and 255.
For example, if the number generated is 0.1, the resulting number will be 25.6.
Next, we need to convert this number to an integer value.
To do this, we use the Math.floor() function. This function rounds down the number to the nearest integer.
For example, if the number is 25.6, the result will be 25.
Let this be the value of the Red channel of the color in RGB Color Space.
Generate 2 more random integers between 0 and 255 and make them the Green and Blue channel values respectively.
This gives us 3 numbers in total and therefore the RGB color.
First, generate a random RGB color as described above.
Then, convert each channel's integer value into a 2 character hexadecimal number (if it's a single character number, prepend a "0") and concatenate them to form the random hexadecimal color value.
For example, if the Red channel value is 25, the Green channel value is 255, and the Blue channel value is 7, the hexadecimal color value would be #19FF07.