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="can" width="400" height="300">Unsupported canvas</canvas>
</body>
</html>
 
canvas{
  border: 3px solid black
}
img{
  border: 3px solid grey
}
 
var can = document.getElementById("can"),
    ctx = can.getContext("2d");
ctx.fillStyle = "#F00";
ctx.fillRect(0, 0, 800, 600);
ctx.fillStyle = "#0F0";
ctx.fillRect(100, 100, 250, 100);
var image = new Image();
image.src = can.toDataURL("image/jpg");
image.style.height = can.height;
image.style.width = can.width;
document.body.appendChild(image);
Output

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

Dismiss x
public
Bin info
GMartignypro
0viewers