MV Showing more that 1 drawing in using canvas ctx

Hello, I would to know if there there are a way to display more that 1 drawing at the same time. I use this script but I unable to display more that 1 drawing:
JavaScript:
const c = document.getElementById("myCanvas");
const ctx = c.getContext('2d');

const path = new Path2D();
c.setAttribute('width', x));
c.setAttribute('height', y);
ctx.lineWidth = 10;
ctx.strokeStyle = 'color';
ctx.beginPath();
ctx.moveTo(($gameVariables.value(x)*48+X), ($gameVariables.value(y)*48+Y));
ctx.lineTo(($gameVariables.value(x)*48+X), ($gameVariables.value(y)*48+Y));
  .
  .
  .
ctx.closePath();
ctx.stroke(); 

const spr = new PIXI.Sprite.from(c);
SceneManager._scene._spriteset.addChild(spr);

The difficulty is I must be able to drawing everywhere on the map in function of their coordinates, and there are a possibility to draw the same or a different one so I cannot just create a script for each possibilties.

At first I used PIXI graphics, but I had some difficulty to clear drawings.
With "SceneManager._scene._spriteset.getChildByName('graph').destroy()" I could only erase them one by one (from the first to the last whereas it will be more convienent if it was from the last to the first) and of course no possibility to erase all them in one go.

So now I try with canvas ctx because I can clear drawings locally with "ctx.clearRect(x, y, width, height)", it's really more flexible to erase drawings in function of coordinates contrary to PIXI graphics. This the scrip I was used with Pixi graphics:

JavaScript:
const s = SceneManager._scene._spriteset;
const g = new PIXI.Graphics()
 g.name = 'graph';
  s.addChild(g);
 const b = new PIXI.Graphics()
 .lineStyle(size, color)
 .moveTo(($gameVariables.value(x)*48+X), ($gameVariables.value(y)*48+Y))
 .lineTo(($gameVariables.value(x)*48+X), ($gameVariables.value(y)*48+Y))
   .
   .
   .
b.name = 'bars';  g.addChild(b);

So if you have an idea about how I can draw more that one time with canvas ctx OR if you know how to clear drawings locally with xy coordinate in using PIXI graphics, it's will be a great help.
I'm not sure what you're trying to draw, but generally your first approach should be to create a Sprite (as defined in the base code) and parent it to the scene or the scene's spriteset when you need more than one instance of something drawn. You should still be able to use canvas stuff on sprites, but you might not even need to.

Maybe just back up and explain what you want to do versus what you think you should do? Can you provide a mockup?
I'm not sure what you're trying to draw, but generally your first approach should be to create a Sprite (as defined in the base code) and parent it to the scene or the scene's spriteset when you need more than one instance of something drawn. You should still be able to use canvas stuff on sprites, but you might not even need to.

Maybe just back up and explain what you want to do versus what you think you should do? Can you provide a mockup?
I'm draw a succession of lines which correspond to border tiles. At first I created spriteset but the problem was I cannot clear them freely, it's why I look for a new approach with canvas but I cannot display more that 1 drawing
If you draw your elements on the Bitmap of a Sprite that you create you can make as many as needed or clear the bitmap.
If you draw your elements on the Bitmap of a Sprite that you create you can make as many as needed or clear the bitmap.
JavaScript:
        const c = document.getElementById("myCanvas");
const ctx = c.getContext('2d');

const path = new Path2D();
c.setAttribute('width', x));
c.setAttribute('height', y);
ctx.lineWidth = 10;
ctx.strokeStyle = 'color';
ctx.beginPath();
ctx.moveTo(($gameVariables.value(x)*48+X), ($gameVariables.value(y)*48+Y));
ctx.lineTo(($gameVariables.value(x)*48+X), ($gameVariables.value(y)*48+Y));
.
.
.
ctx.closePath();
ctx.stroke();

const spr = new PIXI.Sprite.from(c);
SceneManager._scene._spriteset.addChild(spr);

It's my script, so what do I need to change to draw more that 1 element?

Original thread: https://forums.rpgmakerweb.com/threads/showing-more-that-1-drawing-in-using-canvas-ctx.176216/