Skip to content

Instantly share code, notes, and snippets.

/**
* Quick function implementation to convert a color-string of the form "#?[0-9a-fA-F]{3}"
* into a tripe containg rgb color information as a percentage.
*/
def web2Percentage(str: String): (Float, Float, Float) = {
val hexcolor = "([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])".r
val color = if (str startsWith "#") str.tail else str
def hex(str: String): Int =