Skip to content
This repository was archived by the owner on Jun 17, 2023. It is now read-only.

Commit 7a6bf0a

Browse files
author
Amir Khorsandi
committed
avoid divide by zero
1 parent 10b1541 commit 7a6bf0a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Lib/Snapshot/SnapshotTransformView.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,16 @@ private extension SnapshotContainerView {
133133
.translatedBy(x: translateX,
134134
y: translateY)
135135
.scaledBy(x: scale, y: scale)
136-
let rowCount = Int(1.0 / options.pieceSizeRatio.height)
137-
let columnCount = Int(1.0 / options.pieceSizeRatio.width)
136+
var sizeRatioRow = options.pieceSizeRatio.height
137+
if sizeRatioRow == 0 {
138+
sizeRatioRow = 1
139+
}
140+
var sizeRatioColumn = options.pieceSizeRatio.width
141+
if sizeRatioColumn == 0 {
142+
sizeRatioColumn = 1
143+
}
144+
let rowCount = Int(1.0 / sizeRatioRow)
145+
let columnCount = Int(1.0 / sizeRatioColumn)
138146

139147
snapshots.enumerated().forEach { index, view in
140148
let position = SnapshotTransformViewOptions.PiecePosition(

0 commit comments

Comments
 (0)