Simple dragon curve in JavaScript