Can we use hsl instead of rgb in game lab for colors?

I want to randomize colors, but i want to limit the outcomes to a selection of only bright colors.

I think this would be easiest by using HSL where H can be any random number between 0 and 100, but S would always = 100% and L = 50%.

I was hoping that something like this code existed:
fill (hsl(randomNumber(1, 100), 100%, 50%)

My understanding is that RGB doesn’t work the same way. I would have to randomize all 3 parameters which yields many gray and muddy colors.

I can run this code, but it gives me grays etc that I don’t want for the fill:

background(“tomato”);
fill (rgb(randomNumber(1, 255), randomNumber(1, 255), randomNumber(1, 255)));
ellipse(200, 200, 100, 100);

@anne.b.gregal ,

Well, that was some fun research. Natively, HSL isn’t supported by GameLab, but there is a cool formula that was created some time ago that will allow for the conversion.

Here’s more info on that: https://axonflux.com/handy-rgb-to-hsl-and-rgb-to-hsv-color-model-c

Here’s a file showing the implementation.

In this example, I randomize the Hue between 0 and 100 and then keep the S and L at 100% and 50% respectively as per your original proposal. Then I set that to be the background color. It appears to work.

Up to you to adapt it to your project!

Good luck! I like your thinking and would love to see how you implement it.

Mike