From 41c084b27db3607b2636cbfe508da84e8a903031 Mon Sep 17 00:00:00 2001 From: Felix Mau Date: Fri, 11 Mar 2022 14:45:35 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20::=20Update=20documentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NotchGradientLoadingBarController.swift | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/GradientLoadingBar/Classes/NotchGradientLoadingBarController.swift b/GradientLoadingBar/Classes/NotchGradientLoadingBarController.swift index 3609437..43dfac1 100644 --- a/GradientLoadingBar/Classes/NotchGradientLoadingBarController.swift +++ b/GradientLoadingBar/Classes/NotchGradientLoadingBarController.swift @@ -21,9 +21,14 @@ private struct NotchConfig { let largeCircleRadius: CGFloat /// Offset for the center-point of the large circle. + /// + /// - A positive value for the `X` property will move the large circles closer to the center of the screen. A negative offset closer to + /// the corners of the screen. + /// + /// - A positive value for the `Y` property will move the large circles downwards. A negative offset will move them upwards. let largeCircleOffset: CGPoint - /// The transform to be applied to the bezier path. + /// The transform to be applied to the entire bezier path. let transform: CGAffineTransform } @@ -150,7 +155,7 @@ open class NotchGradientLoadingBarController: GradientLoadingBarController { y: height) // Draw line to small-circle underneath and right to `rightNotchPoint`. - bezierPath.addLineTo(x: rightNotchPoint + bottomPathSmallCircleRadius + height, + bezierPath.addLineTo(x: height + rightNotchPoint + bottomPathSmallCircleRadius, y: height) // Draw the small circle right to the `rightNotchPoint`. @@ -162,7 +167,10 @@ open class NotchGradientLoadingBarController: GradientLoadingBarController { clockwise: false) // Draw the large circle left to the `rightNotchPoint`. - bezierPath.addArc(withCenter: CGPoint(x: height + rightNotchPoint - notchConfig.largeCircleRadius - notchConfig.largeCircleOffset.x, + // + // We explicitly ignore the horizontal offset (`notchConfig.largeCircleOffset.x`) here, to have the paths of the + // small- and large-circles end/begin on the same point on the x-axis. + bezierPath.addArc(withCenter: CGPoint(x: height + rightNotchPoint - notchConfig.largeCircleRadius, y: height + smallCircleDiameter + notchConfig.largeCircleOffset.y), radius: notchConfig.largeCircleRadius, startAngle: 0, @@ -170,11 +178,17 @@ open class NotchGradientLoadingBarController: GradientLoadingBarController { clockwise: true) // Draw line to large-circle underneath and right to `leftNotchPoint` - bezierPath.addLineTo(x: height + leftNotchPoint + notchConfig.largeCircleRadius - notchConfig.largeCircleOffset.x, + // + // We explicitly ignore the horizontal offset (`notchConfig.largeCircleOffset.x`) here, to have the paths of the + // small- and large-circles end/begin on the same point on the x-axis. + bezierPath.addLineTo(x: height + leftNotchPoint + notchConfig.largeCircleRadius, y: height + smallCircleDiameter + notchConfig.largeCircleRadius + notchConfig.largeCircleOffset.y) // Draw the large circle right to the `leftNotchPoint`. - bezierPath.addArc(withCenter: CGPoint(x: leftNotchPoint - height + notchConfig.largeCircleRadius + notchConfig.largeCircleOffset.x, + // + // We explicitly ignore the horizontal offset (`notchConfig.largeCircleOffset.x`) here, to have the paths of the + // small- and large-circles end/begin on the same point on the x-axis. + bezierPath.addArc(withCenter: CGPoint(x: leftNotchPoint - height + notchConfig.largeCircleRadius, y: height + smallCircleDiameter + notchConfig.largeCircleOffset.y), radius: notchConfig.largeCircleRadius, startAngle: CGFloat.pi / 2,