Thursday, February 4, 2016

Fast rounded corners

I was always fascinated by ingenious coding, like what Bill Atkinson did for Macintosh back in 1981.

Apple Lisa's 68000 CPU didn't support floating point operations and therefore square roots to calculate circle wasn't on the table.

Bill found out, that because sum of a sequence of odd numbers is always a perfect square (like 1 + 3 = 4 and 1 + 3 + 5 + 7 = 16), the only thing he had to do was to iterate until a threshold was reached.

RoundRects