Skip to content

Commit

Permalink
Swift 5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Cole Dunsby committed Oct 28, 2019
1 parent 95856a3 commit 7f1dc9d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.0
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand Down
18 changes: 9 additions & 9 deletions Sources/SwiftSimplify/Point2DRepresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ public protocol Point2DRepresentable {
extension Point2DRepresentable {

public func equalsTo(_ compare: Self) -> Bool {
return self.xValue == compare.xValue && self.yValue == compare.yValue
xValue == compare.xValue && yValue == compare.yValue
}

public func distanceFrom(_ otherPoint: Self) -> Float {
let dx = self.xValue - otherPoint.xValue
let dy = self.yValue - otherPoint.yValue
let dx = xValue - otherPoint.xValue
let dy = yValue - otherPoint.yValue
return (dx * dx) + (dy * dy)
}

Expand Down Expand Up @@ -83,15 +83,15 @@ extension Point2DRepresentable {
}

extension CLLocationCoordinate2D: Point2DRepresentable {
public var xValue: Float { return Float(self.latitude) }
public var yValue: Float { return Float(self.longitude) }
public var xValue: Float { Float(latitude) }
public var yValue: Float { Float(longitude) }

public var cgPoint: CGPoint { return CGPoint(x: self.latitude, y: self.longitude) }
public var cgPoint: CGPoint { CGPoint(x: latitude, y: longitude) }
}

extension CGPoint: Point2DRepresentable {
public var xValue: Float { return Float(self.x) }
public var yValue: Float { return Float(self.y) }
public var xValue: Float { Float(x) }
public var yValue: Float { Float(y) }

public var cgPoint: CGPoint { return self }
public var cgPoint: CGPoint { self }
}
2 changes: 1 addition & 1 deletion Sources/SwiftSimplify/SwiftSimplify.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public struct SwiftSimplify {
public extension Array where Element: Point2DRepresentable {

func simplify(tolerance: Float? = nil, highestQuality: Bool = true) -> [Element] {
return SwiftSimplify.simplify(self, tolerance: tolerance, highestQuality: highestQuality)
SwiftSimplify.simplify(self, tolerance: tolerance, highestQuality: highestQuality)
}

}
8 changes: 4 additions & 4 deletions Sources/SwiftSimplify/UIBezierPath+CGPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,19 @@ fileprivate extension CGPoint {
/// - Parameter p2: other point.
/// - Returns: mid point.
func midPointForPointsTo(_ p2: CGPoint) -> CGPoint {
return CGPoint(x: (x + p2.x) / 2, y: (y + p2.y) / 2)
CGPoint(x: (x + p2.x) / 2, y: (y + p2.y) / 2)
}

/// Control point to another point from receiver.
///
/// - Parameter p2: other point.
/// - Returns: control point for quad curve.
func controlPointToPoint(_ p2:CGPoint) -> CGPoint {
var controlPoint = self.midPointForPointsTo(p2)
var controlPoint = midPointForPointsTo(p2)
let diffY = abs(p2.y - controlPoint.y)
if self.y < p2.y {
if y < p2.y {
controlPoint.y = controlPoint.y + diffY
} else if ( self.y > p2.y ) {
} else if y > p2.y {
controlPoint.y = controlPoint.y - diffY
}
return controlPoint
Expand Down
2 changes: 1 addition & 1 deletion iOSDemoApp/RenderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class RenderView: UIView {

func renderPath(path: CGPath) {
self.path = path
self.setNeedsDisplay()
setNeedsDisplay()
}

override func draw(_ rect: CGRect) {
Expand Down

0 comments on commit 7f1dc9d

Please sign in to comment.