nearestNeighbor = function nearestNeighbor(src, dst) {
                var pos = 0;
                for (var y = 0; y < dst.height; y++) {
                  for (var x = 0; x < dst.width; x++) {
                    var srcX = Math.floor(x * src.width / dst.width);
                    var srcY = Math.floor(y * src.height / dst.height);
                    var srcPos = (srcY * src.width + srcX) * 4;
                    dst.data[pos++] = src.data[srcPos++]; // R
                    dst.data[pos++] = src.data[srcPos++]; // G
                    dst.data[pos++] = src.data[srcPos++]; // B
                    dst.data[pos++] = src.data[srcPos++]; // A
                  }
                }
              }
Resize the image to a new width and height. To make the image scale
proportionally, use 0 as the value for the wide or high parameter.
For instance, to make the width of an image 150 pixels, and change
the height using the same proportion, use resize(150, 0).

@method resize
@param {Number} width the resized image width
@param {Number} height the resized image height
@example
<div><code>
let img;

function preload() {
  img = loadImage('assets/rockies.jpg');
}
function draw() {
  image(img, 0, 0);
}

function mousePressed() {
  img.resize(50, 100);
}
</code></div>

@alt
image of rocky mountains. zoomed in