MZ How to draw a line in a window?

What it says on the tin.


Just need a function to draw a line within an existing window. Ideally to be able to control the overall size and color as well
Unfortunately, no "drawLine" function in the core code (https://developer.rpgmakerweb.com/rpg-maker-mz/Bitmap.html), but you can use drawRect like this:

Code:
const color = ColorManager.textColor(1) // <-- RPG Maker Text Color Code goes here!!
this.contents.fillRect(x, y, w, h, color)

Doesn't work for diagonal lines, obviously.
durf. Idk why i dinn't thinnk to just do a rectangle x'D

Thank you @Aerosys
drawHorzLine(n * line_height)

same thing.
no drawLine, but drawHorzLine
drawHorzLine(n * line_height)
For MZ: This methods exists only in ShopNumberWindow
For MV: exists only in Window_Status

Calling this function in a custom window will not work without extra-steps, but you can copy-paste it, of course.
The context property of a Bitmap is an instance of CanvasRenderingContext2D, so you can use the usual methods for drawing a line through that, e.g.
JavaScript:
const ctx = bitmap.context;
ctx.save();
ctx.strokeStyle = colour;
ctx.moveTo(x0, y0);
ctx.lineTo(x1, y1);
ctx.stroke();
ctx.restore();
bitmap._baseTexture.update();
This assumes input values bitmap (a Bitmap reference), colour (CSS colour), and x0, y0, x1, y1 (line endpoint coordinates).
This thread is being closed due to being solved. If you need it reopened, report it to let us know why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-draw-a-line-in-a-window.166267/