![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Korsut |
How can I randomly generate color on the GDS?
![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Korsut |
How can I randomly generate color on the GDS?
![]() |
Reply From: | kidscancode |
By “the GDS” I’m assuming you mean GDScript?
The Color object is documented here:
randf()
generates a random number between 0 and 1:
So to get a random color
var random_color = Color(randf(), randf(), randf())
Note that if you need a “pleasant”-looking color, you need to use a more complex algorithm. See this Stack Overflow question for some examples.
Calinou | 2020-04-22 14:53