import kotlin.random.Random
/*
Generate a random RGBA color string.
Produces full‑range RGB values and a floating‑point opacity.
*/
// Generate a random integer in the range 0..255
fun randomChannel(): Int =
Random.nextInt(0, 256)
// Generate a random opacity in the range 0.0..1.0
fun randomOpacity(): Double =
Random.nextDouble() // full floating‑point precision
// Build a full random RGBA color string
fun randomRgbaColor(): String {
val r = randomChannel()
val g = randomChannel()
val b = randomChannel()
val a = randomOpacity()
// Format as rgba(r, g, b, a) with two decimal places
return "rgba($r, $g, $b, ${"%.2f".format(a)})"
}
fun main() {
val color = randomRgbaColor()
println(color)
}
/*
run:
rgba(201, 145, 45, 0.29)
*/