Created
July 1, 2020 19:14
-
-
Save mattrobmattrob/281e29cd484cd411dbc264dafec4fd71 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add all the stripes on top and bottom of the middle at the same time. | |
// Continue adding until we are outside of the bubble's radius since | |
// this area is clipped anyway. | |
var index = 1 | |
// This calculation determines if the edge of the stripe (center of the current | |
// stripe minus half the stripe width) is within the bubble's radius. | |
while (CGFloat(index) * stripeWidth * 2) - (stripeWidth / 2.0) < bubbleRadius { | |
let offset = CGFloat(index) * stripeWidth * 2 | |
// above the middle | |
context.move(to: CGPoint(x: 0, y: offset)) | |
context.addLine(to: CGPoint(x: maxPathLength, y: offset)) | |
context.strokePath() | |
// below the middle | |
context.move(to: CGPoint(x: 0, y: -offset)) | |
context.addLine(to: CGPoint(x: maxPathLength, y: -offset)) | |
context.strokePath() | |
index += 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment