Home

SimpleCanvasLibrary.js

A simple library for handling basic canvas drawings, callbacks and animations.
Author:
  • Thomas Hinkle
Source:

Example

<html>
   <canvas id="game">
   <script src="http://www.tomhinkle.net/util/SimpleCanvasLibrary.js"></script>
   <script>
       const game = new GameCanvas('game')
       game.addDrawing(
          function ({ctx, elapsed, width, height}) {
              let x = (100 * elapsed/1000) % width;
              let y = height/2
              ctx.beginPath();
              ctx.arc(x,y,20,0,Math.PI*2);
              ctx.stroke();
          }
       );
       game.run();
   </script>
</html>