examples/raster.js
function(pixels, data) {
    const pixel = pixels[0];
    const value = vgi(pixel);
    summarize(value, data.counts);
    if (value >= data.threshold) {
      pixel[0] = 0;
      pixel[1] = 255;
      pixel[2] = 0;
      pixel[3] = 128;
    } else {
      pixel[3] = 0;
    }
    return pixel;
  }
function(pixels, data) {
    const pixel = pixels[0];
    const value = vgi(pixel);
    summarize(value, data.counts);
    if (value >= data.threshold) {
      pixel[0] = 0;
      pixel[1] = 255;
      pixel[2] = 0;
      pixel[3] = 128;
    } else {
      pixel[3] = 0;
    }
    return pixel;
  }
function ( pixels , data ) { const pixel = pixels [ 0 ] ; const value = vgi ( pixel ) ; summarize ( value , data . counts ) ; if ( value >= data . threshold ) { pixel [ 0 ] = 0 ; pixel [ 1 ] = 255 ; pixel [ 2 ] = 0 ; pixel [ 3 ] = 128 ; } else { pixel [ 3 ] = 0 ; } return pixel ; }
Run calculations on pixel data.
@param {Array} pixels List of pixels (one per source).
@param {Object} data User data object.
@return {Array} The output pixel.
Run calculations on pixel data .