Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Challenges and Solutions
Welcome! Here we have a short writeup on how I completed a few challenges I faced on this project. Enjoy!
This one proved to be a bit of a challenge. With no easy way on iOS to have a changing color gradient follow a circle path, so I had to get creative. If a circle with a gradient was so hard to do what's the next best option? Simulate a circle!
func drawRainbowCircle(in context: CGContextRef?, outerRadius: CGFloat, innerRadius: CGFloat, resolution: Float) I create a number of squares which are rotated around an origin point to simulate a circle. The max number of squares is 512. The
resolution argument specifies a number between 0 and 1 which is multiplied by 512 to determine the number of sub-divisions.
Here's a gif illustrating just how this function works (gray images shown for contrast):
As each sub-divison is created, the hue of the sub-division is slightly changed from the previous division, this will lead to the visual illusion of a gradient effect on a circle. Pretty nifty!
After running multiple tests with XCTest's measureBlock the current implementation was very fast and efficient for generating a high quality (simulated) image.