Given an image I upload it's copy at a p5.js canvas. After 2 clicks I record coordinates and I wanna draw a rectangle with this coordinates. However, I cannot find a proper way to do so and draw rectangle at a very wrong place. There is the code https://jsfiddle.net/7gvuqtoj/
//p5 for a rect
function preload(){
img = loadImage('cat.jpg');
}
function setup() {
var canvas = createCanvas(img.width, img.height);
translate(0,0);
// Move the canvas so it’s inside our <div id="sketch-holder">.
// canvas.parent('img');
background(255, 0, 200);
}
function draw(){
image(img,0,0);
rect(koors[0],koors[1],koors[2],koors[3]);
}
Might also have a look at: http://abereznyak.ru/projects/vue/ - working cat example