Draw a straight line directly to the canvas.

So I'm looking to draw a straight line from one point on the screen to another. I've been trawling through the pixi scripts but I fear this is beyond me! If someone could share with me how to do this... or even point me to the right function, Id be super thankful!

I probably should mention that the line needs to change dynamically, so a simple picture of a line won't do.

Thank you!
This sounds more like a math problem... The closest function that similar to drawing a straight line dynamically is moving picture. You may copy or understand its function to try to make your own function. Dunno if this would help tho...

event.PNG


Still don't get what you are trying to do, but when you mention "dynamically" I assume you want to make an object chasing after a point in straight line...?
make your own method

PHP:
    function drawLine(sXY,eXY,l,c,a){
        const graphics = new PIXI.Graphics();
        graphics.lineStyle(l||2, c||0xffffff, a||1);
        return graphics.moveTo(sXY[0],sXY[1]).lineTo(eXY[0], eXY[1]).endFill();
    };

sXY it the starting x and y point of your line.
eXY it the Ending point of your line.
l it the line size
c it the color in hex
a it the alpha.
example: a diag line
PHP:
var line = drawLine([0,0], [1600,900], 4, 0x000000, 0.9)

if you need to dynamically update.
you need use graphics.clear(); inside your update.
I know this is a necropost, but just in case someone finds this in google and asks themselves WHY THIS IS NOT WORKING?

It is because after what JonForum says you need to do this
JavaScript:
SceneManager._scene.addChild(line);

Original thread: https://forums.rpgmakerweb.com/threads/draw-a-straight-line-directly-to-the-canvas.95676/