I published the code for this along with a little explanation of how it works: https://git.sr.ht/~akkartik/fractions.love