Update arc.js

Corrected arcs drawing and extended caching logic to have a chache hit more often.
Function is more or less 20 lines of code shorter, but i really cannot figure out if this implementation has more calculation
than the previous. I couldn't manage to find the error in the old one, i had to overwrite it.