toColor

Takes an ARGB integer color and returns a PolyColor object.


Turn the given hex string into a color.

  • If it is 8 characters long, it is assumed to be in the format #RRGGBBAA (alpha optional)

  • If there is a leading #, it will be removed.

  • If it is 1 character long, the character is repeated e.g. #f ->#ffffff

  • If it is 2 characters long, the character is repeated e.g. #0f ->#0f0f0f

  • If it is 3 characters long, the character is repeated e.g. #0fe ->#00ffee

Throws

if the hex string is not in a valid format

if the hex string is not a valid hex string


fun String.toColor(alpha: Float = 1.0f): PolyColor

See also