<script src="https://assets.codepen.io/3560077/CanvasAnimater.js"></script>
<canvas id="myCanvas"></canvas>
<script src="./script.js"></script>

// create a CanvasAnimater object that targets a canvas element with id='myCanvas'
let canvasAnimater = new CanvasAnimater('myCanvas');

// set Dwitter code string
canvasAnimater.dwitter_code = 'for(i=0;i<9;i++)x.fillRect(400+i*100+S(t)*300,400,50,200)';

// flex the canvas to fill the entire window
canvasAnimater.flex(true);

// enable Dwitter mode with dwitter_scale = true and dwitter_res = true
canvasAnimater.dwitterMode(true, true, true);


// render the animation
canvasAnimater.animate();
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://github.com/smtsjhr/CanvasAnimater.js/blob/6ecb4d5ea3f5d36d3abcdd6c8338d9ccf42638e4/CanvasAnimater.js