SamuelScheit / p5js-node

p5.js port for nodejs canvas
http://p5js.org/
GNU Lesser General Public License v2.1
13 stars 7 forks source link

loadImage throws ReferenceError: Request is not defined #2

Open Yetispapa opened 3 years ago

Yetispapa commented 3 years ago

Hi @Flam3rboy,

I got an exception on p.loadImage in my setup function

code what i'm calling:

let texture = p.loadImage( './assets/my-texture.png');

exception with according file:

/Users/myuser/myProject/node_modules/p5js-node/dist/image/loading_displaying.js:95
    const req = new Request(path, {
                ^

ReferenceError: Request is not defined

main_1.default.prototype.loadImage = function (path, successCallback, failureCallback) {
    main_1.default._validateParameters('loadImage', arguments);
    const pImg = new main_1.default.Image(1, 1, this);
    const self = this;
    const req = new Request(path, {
        method: 'GET',
        mode: 'cors'
    });

Can you give me an advice how to proceed here or is there something wrong in the code?

Thank you in advance

BrennerSpear commented 3 years ago

I'm having a similar problem, I cannot get to loadImage to work at all.

I've tried it in the preload and in the setup functions, both with a relative and absolute paths, and i can't get anything to work

BrennerSpear commented 3 years ago

I can load a canvas image fine directly, but can't load a p5types.Image. I don't think i can cast the Image to the p5Types.Image either

jiito commented 3 years ago

Looks like we are not able to use the loadImage function as it uses Request which is an interface of the Fetch API.