Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <canvas id="canvas"></canvas>
</body>
</html>
 
html, body {
  height: 100%;
  margin: 0;
}
 
var canvas = document.querySelector('#canvas'),
    ctx = canvas.getContext('2d');
var w = 4,
    h = 3;
canvas.width = w;
canvas.height = h;
for (var i = 0; i < w * h; i++) {
  var y = Math.floor(i / w),
      x = i % w,
      fill;
  if (y == 1 || x == 1) {
    fill = '#ccc';
  } else {
    fill = 'white';
  }
  ctx.fillStyle = fill;
  ctx.fillRect(x, y, 1, 1);
}
var url = canvas.toDataURL('image/png');
var style = 'url(\'' + url + '\') no-repeat cover';
var bs = document.querySelector('body').style;
bs.backgroundImage = 'url(' + url + ')';
bs.backgroundRepeat = 'no-repeat';
bs.backgroundSize = 'cover';
bs.backgroundPosition = '50% 50%';
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers