Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos #357

Merged
merged 12 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/WeScan/Common/EditScanCornerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class EditScanCornerView: UIView {
return layer
}()

/// Set stroke color of coner layer
/// Set stroke color of corner layer
public var strokeColor: CGColor? {
didSet {
circleLayer.strokeColor = strokeColor
Expand Down
4 changes: 2 additions & 2 deletions Sources/WeScan/Common/Error.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import Foundation
public enum ImageScannerControllerError: Error {
/// The user didn't grant permission to use the camera.
case authorization
/// An error occured when setting up the user's device.
/// An error occurred when setting up the user's device.
case inputDevice
/// An error occured when trying to capture a picture.
/// An error occurred when trying to capture a picture.
case capture
/// Error when creating the CIImage.
case ciImageCreation
Expand Down
18 changes: 9 additions & 9 deletions Sources/WeScan/Common/Quadrilateral.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public struct Quadrilateral: Transformable {
return quadrilateral
}

/// Checks whether the quadrilateral is withing a given distance of another quadrilateral.
/// Checks whether the quadrilateral is within a given distance of another quadrilateral.
///
/// - Parameters:
/// - distance: The distance (threshold) to use for the condition to be met.
Expand Down Expand Up @@ -122,7 +122,7 @@ public struct Quadrilateral: Transformable {
return true
}

/// Reorganizes the current quadrilateal, making sure that the points are at their appropriate positions.
/// Reorganizes the current quadrilateral, making sure that the points are at their appropriate positions.
/// For example, it ensures that the top left point is actually the top and left point point of the quadrilateral.
mutating func reorganize() {
let points = [topLeft, topRight, bottomRight, bottomLeft]
Expand All @@ -148,24 +148,24 @@ public struct Quadrilateral: Transformable {
bottomLeft = xSortedBottomMostPoints[0]
}

/// Scales the quadrilateral based on the ratio of two given sizes, and optionaly applies a rotation.
/// Scales the quadrilateral based on the ratio of two given sizes, and optionally applies a rotation.
///
/// - Parameters:
/// - fromSize: The size the quadrilateral is currently related to.
/// - toSize: The size to scale the quadrilateral to.
/// - rotationAngle: The optional rotation to apply.
/// - Returns: The newly scaled and potentially rotated quadrilateral.
func scale(_ fromSize: CGSize, _ toSize: CGSize, withRotationAngle rotationAngle: CGFloat = 0.0) -> Quadrilateral {
var invertedfromSize = fromSize
var invertedFromSize = fromSize
let rotated = rotationAngle != 0.0

if rotated && rotationAngle != CGFloat.pi {
invertedfromSize = CGSize(width: fromSize.height, height: fromSize.width)
invertedFromSize = CGSize(width: fromSize.height, height: fromSize.width)
}

var transformedQuad = self
let invertedFromSizeWidth = invertedfromSize.width == 0 ? .leastNormalMagnitude : invertedfromSize.width
let invertedFromSizeHeight = invertedfromSize.height == 0 ? .leastNormalMagnitude : invertedfromSize.height
let invertedFromSizeWidth = invertedFromSize.width == 0 ? .leastNormalMagnitude : invertedFromSize.width
let invertedFromSizeHeight = invertedFromSize.height == 0 ? .leastNormalMagnitude : invertedFromSize.height

let scaleWidth = toSize.width / invertedFromSizeWidth
let scaleHeight = toSize.height / invertedFromSizeHeight
Expand Down Expand Up @@ -193,7 +193,7 @@ public struct Quadrilateral: Transformable {

/// Sorts the given `CGPoints` based on their y value.
/// - Parameters:
/// - points: The poinmts to sort.
/// - points: The points to sort.
/// - Returns: The points sorted based on their y value.
private func sortPointsByYValue(_ points: [CGPoint]) -> [CGPoint] {
return points.sorted { point1, point2 -> Bool in
Expand All @@ -218,7 +218,7 @@ extension Quadrilateral {
///
/// - Parameters:
/// - height: The height of the rect containing the quadrilateral.
/// - Returns: The same quadrilateral in the cartesian corrdinate system.
/// - Returns: The same quadrilateral in the cartesian coordinate system.
func toCartesian(withHeight height: CGFloat) -> Quadrilateral {
let topLeft = self.topLeft.cartesian(withHeight: height)
let topRight = self.topRight.cartesian(withHeight: height)
Expand Down
2 changes: 1 addition & 1 deletion Sources/WeScan/Common/VisionRectangleDetector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import CoreImage
import Foundation
import Vision

/// Class used to detect rectangles from an image.
/// Enum encapsulating static functions to detect rectangles from an image.
@available(iOS 11.0, *)
enum VisionRectangleDetector {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extension CGImagePropertyOrientation {
case .rightMirrored:
self = .rightMirrored
@unknown default:
assertionFailure("Unknow orientation, falling to default")
assertionFailure("Unknown orientation, falling to default")
self = .right
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/WeScan/Extensions/CGPoint+Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import UIKit

extension CGPoint {

/// Returns a rectangle of a given size surounding the point.
/// Returns a rectangle of a given size surrounding the point.
///
/// - Parameters:
/// - size: The size of the rectangle that should surround the points.
/// - Returns: A `CGRect` instance that surrounds this instance of `CGpoint`.
/// - Returns: A `CGRect` instance that surrounds this instance of `CGPoint`.
func surroundingSquare(withSize size: CGFloat) -> CGRect {
return CGRect(x: x - size / 2.0, y: y - size / 2.0, width: size, height: size)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/WeScan/Extensions/UIImage+Orientation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extension UIImage {
/// - Parameters:
/// - rotationAngle: The angle to rotate the image by.
/// - options: Options to apply to the image.
/// - Returns: The new image rotated and optentially flipped (@see options).
/// - Returns: The new image rotated and optionally flipped (@see options).
func rotated(by rotationAngle: Measurement<UnitAngle>, options: RotationOptions = []) -> UIImage? {
guard let cgImage = self.cgImage else { return nil }

Expand Down
4 changes: 2 additions & 2 deletions Sources/WeScan/ImageScannerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public protocol ImageScannerControllerDelegate: NSObjectProtocol {
/// - Discussion: Your delegate's implementation of this method should dismiss the image scanner controller.
func imageScannerControllerDidCancel(_ scanner: ImageScannerController)

/// Tells the delegate that an error occured during the user's scanning experience.
/// Tells the delegate that an error occurred during the user's scanning experience.
///
/// - Parameters:
/// - scanner: The scanner controller object managing the scanning interface.
/// - error: The error that occured.
/// - error: The error that occurred.
func imageScannerController(_ scanner: ImageScannerController, didFailWithError error: Error)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/WeScan/Review/ReviewViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit

/// The `ReviewViewController` offers an interface to review the image after it
/// has been cropped and deskwed according to the passed in quadrilateral.
/// has been cropped and deskewed according to the passed in quadrilateral.
final class ReviewViewController: UIViewController {

private var rotationAngle = Measurement<UnitAngle>(value: 0, unit: .degrees)
Expand Down
2 changes: 1 addition & 1 deletion Sources/WeScan/Scan/CaptureSessionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protocol RectangleDetectionDelegateProtocol: NSObjectProtocol {
withQuad quad: Quadrilateral?
)

/// Called when an error occured with the capture session manager.
/// Called when an error occurred with the capture session manager.
/// - Parameters:
/// - captureSessionManager: The `CaptureSessionManager` that encountered an error.
/// - error: The encountered error.
Expand Down
20 changes: 10 additions & 10 deletions Sources/WeScan/Scan/ShutterButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import UIKit
/// A simple button used for the shutter.
final class ShutterButton: UIControl {

private let outterRingLayer = CAShapeLayer()
private let outerRingLayer = CAShapeLayer()
private let innerCircleLayer = CAShapeLayer()

private let outterRingRatio: CGFloat = 0.80
private let outerRingRatio: CGFloat = 0.80
private let innerRingRatio: CGFloat = 0.75

private let impactFeedbackGenerator = UIImpactFeedbackGenerator(style: .light)
Expand All @@ -31,7 +31,7 @@ final class ShutterButton: UIControl {

override init(frame: CGRect) {
super.init(frame: frame)
layer.addSublayer(outterRingLayer)
layer.addSublayer(outerRingLayer)
layer.addSublayer(innerCircleLayer)
backgroundColor = .clear
isAccessibilityElement = true
Expand All @@ -48,11 +48,11 @@ final class ShutterButton: UIControl {
override func draw(_ rect: CGRect) {
super.draw(rect)

outterRingLayer.frame = rect
outterRingLayer.path = pathForOutterRing(inRect: rect).cgPath
outterRingLayer.fillColor = UIColor.white.cgColor
outterRingLayer.rasterizationScale = UIScreen.main.scale
outterRingLayer.shouldRasterize = true
outerRingLayer.frame = rect
outerRingLayer.path = pathForOuterRing(inRect: rect).cgPath
outerRingLayer.fillColor = UIColor.white.cgColor
outerRingLayer.rasterizationScale = UIScreen.main.scale
outerRingLayer.shouldRasterize = true

innerCircleLayer.frame = rect
innerCircleLayer.path = pathForInnerCircle(inRect: rect).cgPath
Expand Down Expand Up @@ -85,10 +85,10 @@ final class ShutterButton: UIControl {

// MARK: - Paths

private func pathForOutterRing(inRect rect: CGRect) -> UIBezierPath {
private func pathForOuterRing(inRect rect: CGRect) -> UIBezierPath {
let path = UIBezierPath(ovalIn: rect)

let innerRect = rect.scaleAndCenter(withRatio: outterRingRatio)
let innerRect = rect.scaleAndCenter(withRatio: outerRingRatio)
let innerPath = UIBezierPath(ovalIn: innerRect).reversing()

path.append(innerPath)
Expand Down