How can I generate random colours?

How can I generate random colours?
0

#1

I don’t mean just about any random colour bu something which is aesthetically good looking. I understand it’s a bit subjective but still, is there any way to filter out bright, neon, fluorescent and similar colours from the palette ?


#2

Check this out https://www.npmjs.com/package/randomcolor


#3

Thanks a lot, but I’m not sure how to use it


#4

How many random colours do you need?

If you didn’t want to just use random numbers as RGB values, you could have an array of acceptable colours and pick from them randomly.


#5

I intend on using a huge number otherwise the colours are bound to repeat. Maybe 100+


#6

Using Math.random() you can generate three numbers from 0 to 255 and create an RGB value with them. Some of your colors might be very ugly, but they’d be random.


#7

Yeah, I’m currently using that same principle but some colours are just too painful to watch.


#8

This does present an interesting colour theory question - are there certain values that most humans would agree are aesthetically unpleasant, and is there a mathematical pattern underlying that?


#9

I see what you mean about some ugly color combos. There are some colors which should stay back in the 90s. However, I wonder instead of true randomness to determine color, who not use patterned randomness instead?

p5.js does a great job doing that and you can check out their example here: https://p5js.org/examples/hello-p5-interactivity-1.html

Hope this helps :slight_smile: