Logo

Complete Tools

Random Color Generator

Generate random colors

Categories
Color Tools

Color Info

?
HEXA
RGBA
HSLA
HSVA
Type

Types

What is Random Color Generator?

Random Color Generator is a free online application that allows you to create random colors, random gray colors, random bright colors, and random dark colors. You may acquire the color in HEX, RGB, HSL, or HSV format using this tool.

Furthermore, a new random color is generated on every page load or can be generated without reloading the website using the Random Color buttons.

How to generate Random Colors?

Use a random function to produce random values between 0-255 for Green, Red, and Blue to get a random color. You'll get a random RGB color by combining these three random numbers, which you may then convert to your own format, such as HEX or HSL.

Below is a pseudo-code that you can use in any language of your choice to implement:

random_color = { r: Random(0, 255), g: Random(0, 255), b: Random(0, 255) }

How to generate Random Gray Colors?

We start by generating a random number between 0 and 255 to create a random gray color. The Red, Green, and Blue components of the color are then calculated using this value. We acquire a random gray RGB color by combining these three numbers, which you can then transform to your own format, such as HEX or HSL.

You'll find a pseudo-code below that you can use in any programming language.

random_num = Random(0, 255)

gray_color = { r: random_num, g: random_num, b: random_num }

How to generate Random Bright Colors?

We initially generate a random hue to produce a random brilliant color. Then we apply a saturation of 100 and a lightness of 50 to the image. We acquire a random bright HSL color by combining these three values, which you can then translate to your own format, such as HEX or RGB.

Below is a pseudo-code that you can use in any language of your choice to implement:

hls_bright_color = { h: Random(0, 360), s: 100, l: 50 }

Nonetheless, using the W3C Algorithm, we require a brighter color:

color_brightness = (r * 299 + g * 587 + b * 114) / 1000

if color_brightness >= 128 then:
  bright_color
else
  dark_color

To combine the two stages above, the basic solution is to write them in a loop and keep looping till we get an exact bright color.

How to generate Random Dark Colors?

To create a random dark color, we must first create a random bright color by following the instructions in the preceding section.

Then, as seen below, calculate the new RGB value.

R = 255 – R
G = 255 – G
B = 255 – B

How to use Random Color Generator?

  • When you load this page, a new random color will be produced for you.
  • In addition, you can:
    • Press the Random Color button to generate a random color.
    • Press the Random Gray Color button to generate a random gray color.
    • Press the Random Bright Color button to generate a random bright color.
    • Press the Random Dark Color button to generate a random dark color.
  • In the Color Info area, you can copy the value of the selected color in HEX, RGB, HSL, or HSV.
  • The value will be copied to the clipboard.
  • If your browser does not allow you to transfer values to the clipboard via script, you can copy them manually.

Credits

  • color: 🌈 Javascript color conversion and manipulation library.

Comments

Complete Tools
AboutTermsPrivacyContact

Copyright © 2022 Complete Tools. Unless otherwise noted, all code MIT license.


Made with by Complete JavaScript