Draw a image from file in the canvas without using a web server using p5.

As the heading states, I can't figure out how to cleanly do this in p5. Every website I find insist on me using a web server, but that's not an option for me.

I've managed to do this in raw javascript, but would very much prefer to do it cleanly in p5. Here is the javascript code that works for me but creates two canvases which is not desirable for me: The HTML contains a canvas tag and the image tag(and src), the CSS just hides the image from view.

Any help would be appreciated.

function setup() {
  oImage = document.getElementById("kart")

function draw() {
  createCanvas(500, 500);
    var c = document.getElementById("myCanvas");
  var ctx = c.getContext("2d");
  ctx.drawImage(oImage, 10, 10);
  rect(0, 0, 50, 50);


Sign In or Register to comment.