Doubts in calculation of pixels values

I want to know how we got this pixel.push( data[ ( i*cols + j ) * 4 + k ] );

Also i want to ask with what theory behind all these JS code

Hello @anmolwadali,

If you are asking about the formula ( i*cols + j ) * 4 + k.
It is used to map the indexes of the 3D array to a 1D array.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.