function createEtLogique(x, y, id){ var imageObj = new Image(); imageObj.onload = function () { var yoda = new Konva.Image({ x: x, y: y, image: imageObj, width: 100, height: 50, id : "pd", }); // add the shape to the layer layer.add(yoda); layer.batchDraw(); }; imageObj.src = 'img/logiqueet.png'; return imageObj; }