• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Martomate / TriPaint / 9275511596

28 May 2024 07:51PM UTC coverage: 29.682% (+1.8%) from 27.877%
9275511596

push

github

Martomate
Updated to Scala 3.4 and MUnit 1.0

2 of 11 new or added lines in 9 files covered. (18.18%)

430 existing lines in 38 files now uncovered.

401 of 1351 relevant lines covered (29.68%)

0.3 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.73
/src/main/scala/tripaint/model/Color.scala
1
package tripaint.model
2

3
import scalafx.scene.paint.Color as FXColor
4

5
case class Color(r: Double, g: Double, b: Double, a: Double) {
UNCOV
6
  def withAlpha(a: Double): Color = Color(r, g, b, a)
×
7

8
  def +(c2: Color): Color = Color(r + c2.r, g + c2.g, b + c2.b, a + c2.a)
1✔
9

UNCOV
10
  def -(c2: Color): Color = Color(r - c2.r, g - c2.g, b - c2.b, a - c2.a)
×
11

12
  def *(d: Double): Color = Color(r * d, g * d, b * d, a * d)
1✔
13

14
  def /(d: Double): Color = Color(r / d, g / d, b / d, a / d)
1✔
15

UNCOV
16
  def toFXColor: FXColor = FXColor.color(clamp(r), clamp(g), clamp(b), clamp(a))
×
17

18
  def toInt: Int = asInt(a) << 24 | asInt(r) << 16 | asInt(g) << 8 | asInt(b)
1✔
19

20
  private def clamp(v: Double): Double = math.min(math.max(v, 0), 1)
1✔
21

22
  private def asInt(v: Double): Int = (clamp(v) * 255).toInt
1✔
23
}
24

25
object Color {
26
  import scala.language.implicitConversions
27

28
  implicit def fromFXColor(c: FXColor): Color = Color(c.red, c.green, c.blue, c.opacity)
1✔
29

30
  def fromInt(value: Int): Color = Color(
1✔
31
    (value >> 16 & 0xff) / 255.0,
32
    (value >> 8 & 0xff) / 255.0,
33
    (value >> 0 & 0xff) / 255.0,
34
    (value >> 24 & 0xff) / 255.0
35
  )
36

37
  val Black: Color = Color(0, 0, 0, 1)
38
  val Red: Color = Color(1, 0, 0, 1)
39
  val Green: Color = Color(0, 1, 0, 1)
40
  val Blue: Color = Color(0, 0, 1, 1)
41
  val Yellow: Color = Color(1, 1, 0, 1)
42
  val Magenta: Color = Color(1, 0, 1, 1)
43
  val Cyan: Color = Color(0, 1, 1, 1)
44
  val White: Color = Color(1, 1, 1, 1)
45
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc