Skip to content

Commit

Permalink
Add remaining pixel filling code
Browse files Browse the repository at this point in the history
  • Loading branch information
cheonjaeung committed Aug 12, 2023
1 parent c0a352c commit 38d37f4
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ interface SimpleGridCells {
val totalSpacing = spacing * (count - 1)
val totalCellSize = availableSize - totalSpacing
val cellSize = totalCellSize / count
return List(count) { cellSize }
val remainingPixels = cellSize % count
return List(count) { index ->
cellSize + if (remainingPixels > 0 && index == 0) 1 else 0
}
}

override fun equals(other: Any?): Boolean {
Expand Down Expand Up @@ -100,7 +103,10 @@ interface SimpleGridCells {
val totalSpacing = spacing * (count - 1)
val totalCellSize = availableSize - totalSpacing
val cellSize = totalCellSize / count
return List(count) { cellSize }
val remainingPixels = cellSize % count
return List(count) { index ->
cellSize + if (remainingPixels > 0 && index == 0) 1 else 0
}
}

override fun equals(other: Any?): Boolean {
Expand Down

0 comments on commit 38d37f4

Please sign in to comment.