re: Why does the image not display on the canvas? VIEW POST

re: Yeah, but your default value for height and width is undefined. The function drawImage has several configurations of optional arguments, and it pro...

Ok, but how, then, can I resize the image (if I want or need) , but leave the parameters blank if the input value for that doesn't exist? Is there just no way to do that?

You could take the height and the width from the image if they are not provided.

const drawImg = function (src = null, x = 0, y = 0, width, height) {
    if (src === null) {
        return false;
    let i = null;
    const draw = function () {
        const w = width || i.width
        const h = height || i.height
        s.drawImage(i, x, y, w, h);
    i = img("textures/" + src + ".png", function () {
    return true;

Ok, thanks, as I said, the default is it uses the image size, and the image did not appear when I ommited the width or height variables from the function call.......
For reference, this is what the image looks like:

Nevermind, I ommited the width and height parameters from the s.drawImage function, and it still didn't appear.

code of conduct - report abuse