Translation fixes

This commit is contained in:
Ilya Laktyushin
2023-01-26 23:44:50 +04:00
parent bb11c789e2
commit edc737dce1

View File

@@ -78,8 +78,37 @@ public func generateRectsImage(color: UIColor, rects: [CGRect], inset: CGFloat,
context.setBlendMode(.copy)
if useModernPathCalculation {
var rects = rects.map { $0.insetBy(dx: -inset, dy: -inset).offsetBy(dx: -topLeft.x, dy: -topLeft.y) }
if rects.count > 1 {
if rects.count == 1 {
let path = UIBezierPath(roundedRect: rects[0], cornerRadius: outerRadius).cgPath
context.addPath(path)
if stroke {
context.setStrokeColor(color.cgColor)
context.setLineWidth(2.0)
context.strokePath()
} else {
context.fillPath()
}
return
}
var combinedRects: [[CGRect]] = []
var currentRects: [CGRect] = []
for rect in rects {
if rect.width.isZero {
combinedRects.append(currentRects)
currentRects.removeAll()
} else {
currentRects.append(rect)
}
}
if !currentRects.isEmpty {
combinedRects.append(currentRects)
}
for rects in combinedRects {
var rects = rects.map { $0.insetBy(dx: -inset, dy: -inset).offsetBy(dx: -topLeft.x, dy: -topLeft.y) }
let minRadius: CGFloat = 2.0
for _ in 0 ..< rects.count * rects.count {
@@ -186,20 +215,8 @@ public func generateRectsImage(color: UIColor, rects: [CGRect], inset: CGFloat,
} else {
context.fillPath()
}
return
} else {
let path = UIBezierPath(roundedRect: rects[0], cornerRadius: outerRadius).cgPath
context.addPath(path)
if stroke {
context.setStrokeColor(color.cgColor)
context.setLineWidth(2.0)
context.strokePath()
} else {
context.fillPath()
}
return
}
return
}
for i in 0 ..< rects.count {