P
P
Percyvelle12019-05-21 19:25:43
JavaScript
Percyvelle1, 2019-05-21 19:25:43

How to arrange two elements side by side in canvas?

I insert files through input, and they replace each other, but it is necessary that the first one appears first, and on the right, the second
https://jsfiddle.net/Percyvelle/7v9kdjh1/1/

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
profesor08, 2019-05-21
@Percyvelle1

Well, calculate the coordinates of the next picture. This is the width of the previous one.

let prevX = 0;

function handleImage(e){
 ...
  ctx.drawImage(img,  prevX, 0, 300, 300)
  prevX = img.width;
...
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question