Command-line implementation of Penrose tiling in Swift. Translated mostly from the Go and Java versions.
Great explainer on Penrose tiling.
Thread asking if there were any implementations in Swift here.
Also nod to waterskier2007's UIKit version here.
I'd initially used CGFloat, then found when I switched to Double, the number of remaining tiles (all of which had to render) dropped by about a quarter. The better way to do this is with an epsilon, e.g.:
let epsilon: CGFloat = 0.00001
…followed by comparisons like:
abs(lhs.x - rhs.x) < epsilon
That way, numbers that are sufficiently similar will compare as equal, which helps when eliminating duplicate tiles. This dropped tiles to render from 2225 to 1731 for 5 generations.
So that's in the latest commit.
