Skip to content

deirdresm/penrose-simple

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Penrose Tiling

Command-line implementation of Penrose tiling in Swift. Translated mostly from the Go and Java versions.

Great explainer on Penrose tiling.

Example output

Reddit r/Swift Thread

Thread asking if there were any implementations in Swift here.

Also nod to waterskier2007's UIKit version here.

Side Note: Floating Point Comparisons

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.

About

Penrose tiling, simple command-line case

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages