• 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

96.55
/src/main/scala/tripaint/model/image/ImageStorage.scala
1
package tripaint.model.image
2

3
import tripaint.model.Color
4
import tripaint.model.coords.{StorageCoords, TriangleCoords}
5
import tripaint.model.image.format.{SimpleStorageFormat, StorageFormat}
6
import tripaint.util.{EventDispatcher, Tracker}
7

8
import scala.util.Try
9

10
class ImageStorage private (val imageSize: Int, image: RegularImage) {
11
  private val dispatcher = new EventDispatcher[ImageStorage.Event]
1✔
12
  def trackChanges(tracker: Tracker[ImageStorage.Event]): Unit = dispatcher.track(tracker)
1✔
13

UNCOV
14
  final def contains(coords: TriangleCoords): Boolean = coords.y < imageSize
×
15

16
  final def getColor(coords: TriangleCoords): Color =
1✔
17
    val sc = SimpleStorageFormat.transform(coords)
1✔
18
    image.getColor(sc.x, sc.y)
1✔
19

20
  final def setColor(coords: TriangleCoords, col: Color): Unit =
1✔
21
    val before = this.getColor(coords)
1✔
22
    if before != col then
23
      val sc = SimpleStorageFormat.transform(coords)
1✔
24
      image.setColor(sc.x, sc.y, col)
1✔
25
      dispatcher.notify(ImageStorage.Event.PixelChanged(coords, before, col))
1✔
26

27
  def allPixels: IndexedSeq[TriangleCoords] =
1✔
28
    for
1✔
29
      y <- 0 until imageSize
1✔
30
      x <- 0 until 2 * y + 1
1✔
31
    yield TriangleCoords(x, y)
32

33
  def toRegularImage(format: StorageFormat): RegularImage =
1✔
34
    val image = RegularImage.ofSize(imageSize, imageSize)
1✔
35
    for y <- 0 until imageSize do
1✔
36
      for x <- 0 until 2 * y + 1 do
1✔
37
        val tCoords = TriangleCoords(x, y)
38
        val sCoords = format.transform(tCoords)
1✔
39
        image.setColor(sCoords.x, sCoords.y, this.getColor(tCoords))
1✔
40
    image
41
}
42

43
object ImageStorage {
44
  def fill(imageSize: Int, color: Color) =
1✔
45
    new ImageStorage(imageSize, RegularImage.fill(imageSize, imageSize, color))
1✔
46

47
  def fromRegularImage(
1✔
48
      image: RegularImage,
49
      offset: StorageCoords,
50
      format: StorageFormat,
51
      imageSize: Int
52
  ): Try[ImageStorage] = Try {
1✔
53
    val regularImage = RegularImage.tabulate(imageSize, imageSize)((x, y) =>
1✔
54
      val stCoords = format.transform(SimpleStorageFormat.reverse(StorageCoords(x, y)))
1✔
55
      image.getColor(offset.x + stCoords.x, offset.y + stCoords.y)
1✔
56
    )
57
    new ImageStorage(imageSize, regularImage)
1✔
58
  }
59

60
  enum Event:
61
    case PixelChanged(coords: TriangleCoords, from: Color, to: Color)
62
}
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