All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.Random.kt Maven / Gradle / Ivy

There is a newer version: 0.19.1
Show newest version
package com.juul.krayon.color

import kotlin.random.Random

/** Get a random [Color]. If [isOpaque] is `true` (the default), then alpha is guaranteed to be `0xFF`. */
public fun Random.nextColor(isOpaque: Boolean = true): Color = when (isOpaque) {
    true -> Color((0xFF shl SHIFT_ALPHA) or (nextInt() and MASK_RGB))
    false -> Color(nextInt())
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy