Created
January 20, 2013 21:04
-
-
Save Sciss/4581778 to your computer and use it in GitHub Desktop.
string interpolation test for hex (css style) colors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implicit class HexColor(val sc: StringContext) extends AnyVal { | |
def rgb(args: Any*) = sc.parts match { | |
case Seq(t) => | |
require(t.length == 6, "must have length 6") | |
val i = Integer.parseInt(t, 16) | |
new java.awt.Color(i) | |
case _ => sys.error("Parts are unsupported") | |
} | |
} | |
rgb"141f2e" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment