0

I want to generate random light colors using RGB values.

I have already tried giving different range but at sometime it generated some random dark color, which doesn't suit my black theme

Peter O.
  • 32,158
  • 14
  • 82
  • 96
lk1252
  • 11
  • 1
  • 2
  • RGB is very generic. We uses values from 0 to 256, 16 to 235, 0 to 1024, 0.0 to 1.0, 0 to 100, and many more. Sometime we allow negative numbers, or higher values (more bright then white). You should explain where do you use random colours. And if you want better random colours (visually spaced, not to have too many dark and green colours), you may uses other colour space) – Giacomo Catenazzi May 21 '21 at 09:34

1 Answers1

0

You can randomly generate a colour and check if it is 'bright' enough. I set it to a minimum of 255 (full black would be 0). You can increase this if needed.

import random
colour = (0, )
while sum(colour) < 255:
    colour = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
Rutger
  • 593
  • 5
  • 11