ImageData:mapPixel
Transform an image by applying a function to every pixel.

This function is a higher-order function. It takes another function as a parameter, and calls it once for each pixel in the ImageData.

The passed function is called with six parameters for each pixel in turn. The parameters are numbers that represent the x and y coordinates of the pixel and its red, green, blue and alpha values. The function should return the new red, green, blue, and alpha values for that pixel.

function pixelFunction(x, y, r, g, b, a)

-- template for defining your own pixel mapping function

-- perform computations giving the new values for r, g, b and a

-- ...

return r, g, b, a

end

In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1.
ImageData:mapPixel( pixelFunction, x, y, width, height )
pixelFunction function Function to apply to every pixel.
x (0) number The x-axis of the top-left corner of the area within the ImageData to apply the function to.
y (0) number The y-axis of the top-left corner of the area within the ImageData to apply the function to.
width (ImageData:getWidth()) number The width of the area within the ImageData to apply the function to.
height (ImageData:getHeight()) number The height of the area within the ImageData to apply the function to.