Skip to content

Commit 09ca153

Browse files
authored
Merge pull request #243 from netzwerg/master
Add toHex to Color
2 parents 193b1ee + 82141b4 commit 09ca153

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/main/scala/org/scalajs/dom/ext/Extensions.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class EasySeq[T](jsLength: Int, jsApply: Int => T) extends Seq[T] {
4242
case class Color(r: Int, g: Int, b: Int) {
4343
override def toString() = s"rgb($r, $g, $b)"
4444

45+
def toHex: String = f"#$r%02x$g%02x$b%02x"
46+
4547
def *(c: Color) = Color(r * c.r, g * c.g, b * c.b)
4648

4749
def +(c: Color) = Color(r + c.r, g + c.g, b + c.b)

0 commit comments

Comments
 (0)