function binarySearch(canvas, gl, minVal, maxVal) {
  const interval = (maxVal - minVal) / 2;
  if (minVal == maxVal || interval < 1024) {
    return minVal;
  }

  const middle = Math.floor(minVal + interval);
  canvas.width = middle;
  canvas.height = middle;
  if (log) {
    console.log('binarysearch', middle);
  }

  if (isGlContextFillingTheCanvas(gl)) {
    return binarySearch(canvas, gl, middle, maxVal);
  }
  return binarySearch(canvas, gl, minVal, middle);
}
// Search with minVal inclusive, maxVal exclusive
Search with minVal inclusive, maxVal exclusive
Search with minVal inclusive maxVal exclusive
function binarySearch(canvas, gl, minVal, maxVal) {
  const interval = (maxVal - minVal) / 2;
  if (minVal == maxVal || interval < 1024) {
    return minVal;
  }
  const middle = Math.floor(minVal + interval);
  canvas.width = middle;
  canvas.height = middle;
  if (log) {
    console.log('binarysearch', middle);
  }
  if (isGlContextFillingTheCanvas(gl)) {
    return binarySearch(canvas, gl, middle, maxVal);
  }
  return binarySearch(canvas, gl, minVal, middle);
}
function binarySearch ( canvas , gl , minVal , maxVal ) { const interval = ( maxVal - minVal ) / 2 ; if ( minVal == maxVal || interval < 1024 ) { return minVal ; } const middle = Math . floor ( minVal + interval ) ; canvas . width = middle ; canvas . height = middle ; if ( log ) { console . log ( 'binarysearch' , middle ) ; } if ( isGlContextFillingTheCanvas ( gl ) ) { return binarySearch ( canvas , gl , middle , maxVal ) ; } return binarySearch ( canvas , gl , minVal , middle ) ; }
Search with minVal inclusive, maxVal exclusive
Search with minVal inclusive maxVal exclusive