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

Martomate / TriPaint / 8896742719

30 Apr 2024 02:39PM UTC coverage: 27.877% (+0.3%) from 27.558%
8896742719

push

github

Martomate
Fixed major performance issue

4 of 6 new or added lines in 1 file covered. (66.67%)

40 existing lines in 5 files now uncovered.

373 of 1338 relevant lines covered (27.88%)

0.28 hits per line

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

87.5
/src/main/scala/tripaint/model/effects/LocalEffect.scala
1
package tripaint.model.effects
2

3
import tripaint.model.{Color, ColorLookup, FloodFillSearcher, ImageGrid, ImageGridColorLookup}
4
import tripaint.model.coords.{GlobalPixCoords, GridCoords, PixelCoords}
5

6
import scalafx.scene.paint.Color as FXColor
7

8
abstract class LocalEffect extends Effect {
9

10
  protected def predicate(image: ColorLookup, here: GlobalPixCoords)(
11
      coords: GlobalPixCoords,
12
      color: Color
13
  ): Boolean
14

15
  protected def weightedColor(image: ColorLookup, here: GlobalPixCoords)(
16
      coords: GlobalPixCoords
17
  ): (Double, Color)
18

1✔
19
  override def action(images: Seq[GridCoords], grid: ImageGrid): Unit = {
1✔
20
    val colorLookup = new ImageGridColorLookup(grid)
21

1✔
22
    val searcher = new FloodFillSearcher(colorLookup)
1✔
23
    val allChanges = for (imageCoords <- images) yield {
1✔
24
      val image = grid(imageCoords).get.storage
25

1✔
26
      val newVals = for (here <- image.allPixels) yield {
1✔
27
        val coords = PixelCoords(here, imageCoords)
1✔
28
        val coordsGlobal = coords.toGlobal(grid.imageSize)
29

30
        val cols = searcher
×
31
          .search(coordsGlobal, predicate(colorLookup, coordsGlobal))
1✔
32
          .map(weightedColor(colorLookup, coordsGlobal))
33

1✔
34
        val numCols = cols.foldLeft(0d)(_ + _._1)
1✔
35
        here -> (cols.map((w, c) => c * w).reduce(_ + _) / numCols)
36
      }
1✔
37
      imageCoords -> newVals
38
    }
1✔
39
    for ((im, vals) <- allChanges) {
1✔
UNCOV
40
      val image = grid(im).get.storage
×
41
      for ((coords, color) <- vals) image.setColor(coords, color)
42
    }
43
  }
44
}
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