I am iterating over some image data pulled from a canvas
like so:
var imageData = this.context.getImageData(0, 0, this.el.width, this.el.height)
Corrected and tested version of code:
var x = (i / 4) % this.el.width;
var y = Math.floor((i / 4) / this.el.width);
A Simple Arithmetic Sequence:
Divide the linear position by the width. That's your Y-coordinate. Multiply that Y-coordinate by the width, and subtract that value from the linear position. The result is the X coordinate.
Also note, you will have to divide the linear position by 4 since it is RGBA.