toHex

fun Color.toHex(includePrefix: Boolean = true, prefix: String = "#", alwaysIncludeAlpha: Boolean = false): String

Convert the color to a hex string.

The hex digits are always uppercase. The prefix is written exactly as given.

Receiver

Color to convert.

Return

String hex representation of the color.

Parameters

includePrefix

Whether to start the string with prefix.

prefix

The text written before the hex digits, # by default. Pass 0x for a Kotlin literal.

alwaysIncludeAlpha

Whether to write the alpha byte for an opaque color too. A translucent color always gets it.