I'm attempting to import an image generated by a function in the gaborgen.js library.
The goal is to create a Gabor patch image using this library, save it as an image variable in p5, and then show it on the canvas.
The library has a gaborgen() function that requires two parameters. For example, calling gaborgen(50, 40) would produce a Gabor patch based on those values. The returned image from the library is in base64 PNG format.
My initial attempt to load the image was unsuccessful, resulting in just a blank screen in the sketch.
var img;
function setup() {
createCanvas(640, 360);
img = createImg(gaborgen(50, 40));
}
function draw(){
background(0);
image(img, 0, 0, img.elt.width, img.elt.height);
}
The gaborgen() function in the Gaborgen.js library looks like this:
gaborgen = function(tilt, sf) {
// Function code here
};
Is there a way for me to successfully load a base64 PNG image returned by a function into p5.js?