p5-node icon indicating copy to clipboard operation
p5-node copied to clipboard

Tint doesn't seem to work on images

Open galipmedia opened this issue 4 years ago • 2 comments
trafficstars

Placing a p.tint above a p.image it results in...

ReferenceError: ImageData is not defined

galipmedia avatar Aug 29 '21 06:08 galipmedia

@andithemudkip Have the same problem. Can you give us an advice?

Yetispapa avatar Oct 26 '21 21:10 Yetispapa

@galipmedia @Yetispapa The implementation wasn't properly done, The library assumed DataImage exists in node. It's also referenced in many places in the code.

I found a workaround that you might want to use for the time being. In node_modules/node-p5/index.js:18391

You replace e instanceof ImageData with e.data. the code will look like the following:

return e.data
              ? e.data
              : e.getContext("2d").getImageData(0, 0, e.width, e.height).data;

p5.tint will work again until, hopefully, a new version is released where DataImage is defined/imported.

Javascipt avatar Nov 21 '21 22:11 Javascipt