An HTML5 canvas framework with a functional approach to state