JavaScript for drawing on canvas only with pixels

by Andy Bulka

HTML

<canvas id="myCanvas" width="300" height="210">
  <p>Some default content can appear here.</p>
</canvas>
<p>HP42S canvas!</p>

JavaScript

// JavaScript for drawing on canvas only with pixels

function pixel(x, y, canvas){
  canvas.fillRect(x,y,1,1);
}

function draw() {
  var canvas = document.getElementById('myCanvas');
  if (canvas.getContext) {
    var ctx = canvas.getContext('2d');

		// draw a line
    for (let i=0; i<600; i++)
      point(i, 10, ctx)
    
  }
}

draw();