Skip to content
This repository was archived by the owner on Jul 1, 2022. It is now read-only.

Commit 1b7e86a

Browse files
Use the existing degrees to radians func, use CGFloat
1 parent b2e1d72 commit 1b7e86a

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

ALCameraViewController/Utilities/Utilities.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import UIKit
1010
import AVFoundation
1111

12-
internal func radians(_ degrees: Double) -> Double {
13-
return degrees / 180 * Double.pi
12+
internal func radians(_ degrees: CGFloat) -> CGFloat {
13+
return degrees / 180 * .pi
1414
}
1515

1616
internal func localizedString(_ key: String) -> String {
@@ -24,7 +24,7 @@ internal func localizedString(_ key: String) -> String {
2424
return NSLocalizedString(key, tableName: CameraGlobals.shared.stringsTable, bundle: bundle, comment: key)
2525
}
2626

27-
internal func currentRotation(_ oldOrientation: UIInterfaceOrientation, newOrientation: UIInterfaceOrientation) -> Double {
27+
internal func currentRotation(_ oldOrientation: UIInterfaceOrientation, newOrientation: UIInterfaceOrientation) -> CGFloat {
2828
switch oldOrientation {
2929
case .portrait:
3030
switch newOrientation {

ALCameraViewController/ViewController/CameraViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,8 @@ open class CameraViewController: UIViewController {
391391
internal func rotate(actualInterfaceOrientation: UIInterfaceOrientation) {
392392

393393
if lastInterfaceOrientation != nil {
394-
let lastTransform = CGAffineTransform(rotationAngle: CGFloat(radians(currentRotation(
395-
lastInterfaceOrientation!, newOrientation: actualInterfaceOrientation))))
394+
let lastTransform = CGAffineTransform(rotationAngle: radians(currentRotation(
395+
lastInterfaceOrientation!, newOrientation: actualInterfaceOrientation)))
396396
setTransform(transform: lastTransform)
397397
}
398398

ALCameraViewController/ViewController/ConfirmViewController.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,17 +328,15 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate {
328328

329329
extension UIImage {
330330
func crop(rect: CGRect) -> UIImage {
331-
let rad = {(_ deg: CGFloat) -> CGFloat in
332-
return deg / 180.0 * .pi
333-
}
331+
334332
var rectTransform: CGAffineTransform
335333
switch imageOrientation {
336334
case .left:
337-
rectTransform = CGAffineTransform(rotationAngle: rad(90)).translatedBy(x: 0, y: -size.height)
335+
rectTransform = CGAffineTransform(rotationAngle: radians(90)).translatedBy(x: 0, y: -size.height)
338336
case .right:
339-
rectTransform = CGAffineTransform(rotationAngle: rad(-90)).translatedBy(x: -size.width, y: 0)
337+
rectTransform = CGAffineTransform(rotationAngle: radians(-90)).translatedBy(x: -size.width, y: 0)
340338
case .down:
341-
rectTransform = CGAffineTransform(rotationAngle: rad(-180)).translatedBy(x: -size.width, y: -size.height)
339+
rectTransform = CGAffineTransform(rotationAngle: radians(-180)).translatedBy(x: -size.width, y: -size.height)
342340
default:
343341
rectTransform = CGAffineTransform.identity
344342
}

0 commit comments

Comments
 (0)