lib/sphere/from-raster.js
function _populateSelectionGrid(bmp, geo, w, h) {

  var w_rect = τ / w,
      h_rect = π / h;

  var min_x = floor(geo.min_λ / w_rect + w / 2),
      max_x = ceil(geo.max_λ / w_rect + w / 2),
      min_y = floor(geo.min_φ / h_rect + h / 2),
      max_y = ceil(geo.max_φ / h_rect + h / 2);

  for (let x = min_x; x <= max_x; x += 1) {

    for (let y = min_y; y <= max_y; y += 1) {

      bmp.write(x % w, y, inside(
        [x * w_rect - π, y * h_rect - π / 2],
        geo.vertices
      ));

    }

  }

  return {
    min_x,
    max_x,
    min_y,
    max_y
  };

}
function _populateSelectionGrid(bmp, geo, w, h) {

  var w_rect = τ / w,
      h_rect = π / h;

  var min_x = floor(geo.min_λ / w_rect + w / 2),
      max_x = ceil(geo.max_λ / w_rect + w / 2),
      min_y = floor(geo.min_φ / h_rect + h / 2),
      max_y = ceil(geo.max_φ / h_rect + h / 2);

  for (let x = min_x; x <= max_x; x += 1) {

    for (let y = min_y; y <= max_y; y += 1) {

      bmp.write(x % w, y, inside(
        [x * w_rect - π, y * h_rect - π / 2],
        geo.vertices
      ));

    }

  }

  return {
    min_x,
    max_x,
    min_y,
    max_y
  };

}
Writes booleans indicating which pixel corners lay inside a field's edges to a bitmap.
Returns the bounds within which writing took place.

@param bmp - the Bitmap instance containing the grid of values
@param geo - result of `_fieldGeometry` analysis
@param w - width of the dataset
@param h - height of the dataset
@returns {{min_x: number, max_x: number, min_y: number, max_y: number}}
@private