I'm using p5.js - a javascript library - to capture images from a news API. I would like these images to be superimposed, but opaque, so that the images blend.
I'm not able to apply direct opacity to the javascript code. I can change the position of the images (photos.position (x, y);), but I can not find the way to apply opacity.
function setup() {
createCanvas(900,600);
loadJSON("https://newsapi.org....ec6490",gotData);
}
function gotData(data) {
console.log(data);
var img = data.articles;
var imgs = [];
for (var i = 0; i < img.length; i++) {
imgs.push(img[i].urlToImage);
var fotos = createImg(img[i].urlToImage);
fotos.position(0, 0);
}
}
One solution I found by reading some posts here in stackflow was manually changing the opacity of the images one by one through the HTML browser inspector, but this is only for a few images.
But this is impossible in the case of 2,000 images, for example. I need to automate this process.
So, how do I apply opacity in an image - DOM element directly through the javascript code?