dotPos(density, stageWidth, stageHeight) {
const imageData = this.ctx.getImageData(0, 0, stageWidth, stageHeight).data;
const imageData = this.ctx.getImageData(0, 0, stageWidth, stageHeight).data;
const particles = [];
let i = 0;
let width = 0;
let pixel;
for (let height = 0; height < stageHeight; height++) {
++i;
const slide = i % 2 === 0;
width = 0;
if (slide === 1) {
width += 6;
}
for (width; width < stageWidth; width += density) {
pixel = imageData[(width + height * stageWidth) * 4 - 1];
if (pixel !== 0 && width > 0 && width < stageWidth && height > 0 && height < stageHeight) {
particles.push({
x: width,
h: height,
});
}
}
}
I'm studying the code above but I don't know what the below line means:
pixel = imageData[(width + height * stageWidth) * 4 - 1];
please help me.