patch-gl.js
function flipImageData (data, width, height) {
  const numComponents = data.length / (width * height)
  for (let y = 0; y < height / 2; y++) {
    for (let x = 0; x < width; x++) {
      for (let c = 0; c < numComponents; c++) {
        const i = (y * width + x) * numComponents + c
        const flippedI = ((height - y - 1) * width + x) * numComponents + c
        const tmp = data[i]
        data[i] = data[flippedI]
        data[flippedI] = tmp
      }
    }
  }
}
function flipImageData (data, width, height) {
  const numComponents = data.length / (width * height)
  for (let y = 0; y < height / 2; y++) {
    for (let x = 0; x < width; x++) {
      for (let c = 0; c < numComponents; c++) {
        const i = (y * width + x) * numComponents + c
        const flippedI = ((height - y - 1) * width + x) * numComponents + c
        const tmp = data[i]
        data[i] = data[flippedI]
        data[flippedI] = tmp
      }
    }
  }
}
function flipImageData ( data , width , height ) { const numComponents = data . length / ( width * height ) for ( let y = 0 ; y < height / 2 ; y ++ ) { for ( let x = 0 ; x < width ; x ++ ) { for ( let c = 0 ; c < numComponents ; c ++ ) { const i = ( y * width + x ) * numComponents + c const flippedI = ( ( height - y - 1 ) * width + x ) * numComponents + c const tmp = data [ i ] data [ i ] = data [ flippedI ] data [ flippedI ] = tmp } } } }
Flipping array buffer in place
Flipping array buffer in place