var width = 10;
var data = image.data;
var height = 10;
for ( var x = 0; x < width; x++ ) {
for ( var y = 0; y < height; y++ )
var index = 4 * (y * height + x); // 0
var local_variable = ArbitraryClassInstance.getBrightness(x, y); // 0
data[ index ] = ArbitraryClassInstance.getBrightness(x, y); // 0 for both index/call
data[ index + 1 ] = ArbitraryClassInstance.getBrightness(x, y); // 0 for both index/call
}
}
context.putImageData(image, 0, 0);
Both index and local_variable are equalled to zero when I execute the code. Image is a javascript image object, data is the image data, and width and height are the dimensions of the image. The class returns brightness.