refactor(Turnips): move Path extension for Hermite curve into its own file
MODIFY
ACHNBrowserUI/ACHNBrowserUI.xcodeproj/project.pbxproj
ACHNBrowserUI/ACHNBrowserUI.xcodeproj/project.pbxproj
4C7F2F782461F10300930928 /* TurnipsChartVerticalLegend.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C7F2F772461F10300930928 /* TurnipsChartVerticalLegend.swift */; };
4C7FE78324574FB50011E8AB /* ActivityIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C7FE78224574FB50011E8AB /* ActivityIndicator.swift */; };
4C7FE789245B57A10011E8AB /* AdaptsToSoftwareKeyboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C7FE788245B57A10011E8AB /* AdaptsToSoftwareKeyboard.swift */; };
+ 4CF8049B24635E54005C6C63 /* Path.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CF8049A24635E54005C6C63 /* Path.swift */; };
68345579244C994C0072FC0C /* LikeButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68345578244C994C0072FC0C /* LikeButtonView.swift */; };
68345589244E4DEF0072FC0C /* ACNHEvents in Frameworks */ = {isa = PBXBuildFile; productRef = 68345588244E4DEF0072FC0C /* ACNHEvents */; };
6834558B244E4E0B0072FC0C /* DashboardEventTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6834558A244E4E0B0072FC0C /* DashboardEventTextView.swift */; };
4C7F2F772461F10300930928 /* TurnipsChartVerticalLegend.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TurnipsChartVerticalLegend.swift; sourceTree = "<group>"; };
4C7FE78224574FB50011E8AB /* ActivityIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityIndicator.swift; sourceTree = "<group>"; };
4C7FE788245B57A10011E8AB /* AdaptsToSoftwareKeyboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdaptsToSoftwareKeyboard.swift; sourceTree = "<group>"; };
+ 4CF8049A24635E54005C6C63 /* Path.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Path.swift; sourceTree = "<group>"; };
68345578244C994C0072FC0C /* LikeButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LikeButtonView.swift; sourceTree = "<group>"; };
6834558A244E4E0B0072FC0C /* DashboardEventTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardEventTextView.swift; sourceTree = "<group>"; };
687B5767244A030700C1E86F /* TurnipsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TurnipsView.swift; sourceTree = "<group>"; };
children = (
693E72A1245EA84400CD26F4 /* View.swift */,
693E729F245EA5A000CD26F4 /* Text.swift */,
+ 4CF8049A24635E54005C6C63 /* Path.swift */,
);
path = extensions;
sourceTree = "<group>";
693E72A2245EA84500CD26F4 /* View.swift in Sources */,
69AF8C51243E283D001DD9CB /* AppDelegate.swift in Sources */,
4C7F2F782461F10300930928 /* TurnipsChartVerticalLegend.swift in Sources */,
+ 4CF8049B24635E54005C6C63 /* Path.swift in Sources */,
693E728E245D71DD00CD26F4 /* UIState.swift in Sources */,
68BA5834244B9D4100B53811 /* DashboardView.swift in Sources */,
692C0B8524517837004847A1 /* DashboardCollectionProgressSection.swift in Sources */,

MODIFY
ACHNBrowserUI/ACHNBrowserUI/views/turnips/charts/TurnipsChartMinMaxCurves.swift
ACHNBrowserUI/ACHNBrowserUI/views/turnips/charts/TurnipsChartMinMaxCurves.swift
@@ -47,51 +47,3 @@ struct TurnipsChartMinMaxCurves: Shape {
return path
}
}
-
-private extension CGPoint {
- static func +(lhs: Self, rhs: Self) -> Self {
- Self(x: lhs.x + rhs.x, y: lhs.y + rhs.y)
- }
-
- static func -(lhs: Self, rhs: Self) -> Self {
- Self(x: lhs.x - rhs.x, y: lhs.y - rhs.y)
- }
-
- static func /(lhs: Self, rhs: CGFloat) -> Self {
- Self(x: lhs.x/rhs, y: lhs.y/rhs)
- }
-
- static func *(lhs: Self, rhs: CGFloat) -> Self {
- Self(x: lhs.x * rhs, y: lhs.y * rhs)
- }
-}
-
-// Inspired from https://github.com/FlexMonkey/SmoothScribble/blob/master/SmoothScribble/extensions/UIBezierPathExtension.swift
-extension Path {
- mutating func addHermiteCurvedLines(points : [CGPoint], alpha : CGFloat = 1/3) {
- guard !points.isEmpty else { return }
- move(to: points.first ?? .zero)
-
- for (i, currentPoint) in points.enumerated() {
- if currentPoint == points.last { continue }
-
- let previousPoint = points[max(0, i - 1)]
- let nextPoint = points[min(i + 1, points.count - 1)]
-
- let previousDerivative = (nextPoint - previousPoint)/2
- let control1 = currentPoint + previousDerivative * alpha
-
- let furtherPoint = points[min(i + 2, points.count - 1)]
-
- let nextDerivative: CGPoint
- if i < points.count - 1 {
- nextDerivative = (furtherPoint - currentPoint)/2
- } else {
- nextDerivative = (nextPoint - currentPoint)/2
- }
- let control2 = nextPoint - nextDerivative * alpha
-
- self.addCurve(to: nextPoint, control1: control1, control2: control2)
- }
- }
-}

refactor(Turnips): move Path extension for Hermite curve into its own file