plugin/boomerang/boomerang-1.0.0.js
/**
	 * Given a 2D array representing the screen and a list of rectangular dimension tuples, turn on the screen pixels that match the dimensions.
	 * Previously set pixels that are also set with the current call will be overwritten with the new value of pixelValue
	 * @param {number[][]} currentPixels A 2D sparse array of numbers representing set pixels or undefined if no pixels are currently set.
	 * @param {number[][]} dimList A list of rectangular dimension tuples in the form [height, width, top, left] for resources to be painted on the virtual screen
	 * @param {number} pixelValue The numeric value to set all new pixels to
	 * @returns {number[][]} An updated version of currentPixels.
	 */
Given a 2D array representing the screen and a list of rectangular dimension tuples, turn on the screen pixels that match the dimensions.
Previously set pixels that are also set with the current call will be overwritten with the new value of pixelValue
@param {number[][]} currentPixels A 2D sparse array of numbers representing set pixels or undefined if no pixels are currently set.
@param {number[][]} dimList A list of rectangular dimension tuples in the form [height, width, top, left] for resources to be painted on the virtual screen
@param {number} pixelValue The numeric value to set all new pixels to
@returns {number[][]} An updated version of currentPixels.
Given a 2D array representing the screen and a list of rectangular dimension tuples turn on the screen pixels that match the dimensions . Previously set pixels that are also set with the current call will be overwritten with the new value of pixelValue @param { number [] [] } currentPixels A 2D sparse array of numbers representing set pixels or undefined if no pixels are currently set . @param { number [] [] } dimList A list of rectangular dimension tuples in the form [ height width top left ] for resources to be painted on the virtual screen @param { number } pixelValue The numeric value to set all new pixels to @returns { number [] [] } An updated version of currentPixels .
function mergePixels(currentPixels, dimList, pixelValue) {
		var s = BOOMR.window.screen,
		    h = s.height, w = s.width;
		return dimList.reduce(
			function(acc, val) {
				var x_min, x_max,
				    y_min, y_max,
				    x, y;
				x_min = Math.max(0, val[3]);
				y_min = Math.max(0, val[2]);
				x_max = Math.min(val[3] + val[1], w);
				y_max = Math.min(val[2] + val[0], h);
				if (x_min >= x_max || y_min >= y_max) {
					return acc;
				}
				for (y = y_min; y < y_max; y++) {
					if (!acc[y]) {
						acc[y] = [];
					}
					for (x = x_min; x < x_max; x++) {
						acc[y][x] = pixelValue;
					}
				}
				return acc;
			},
			currentPixels || []
		);
	}
function mergePixels ( currentPixels , dimList , pixelValue ) { var s = BOOMR . window . screen , h = s . height , w = s . width ; return dimList . reduce ( function ( acc , val ) { var x_min , x_max , y_min , y_max , x , y ; x_min = Math . max ( 0 , val [ 3 ] ) ; y_min = Math . max ( 0 , val [ 2 ] ) ; x_max = Math . min ( val [ 3 ] + val [ 1 ] , w ) ; y_max = Math . min ( val [ 2 ] + val [ 0 ] , h ) ; if ( x_min >= x_max || y_min >= y_max ) { return acc ; } for ( y = y_min ; y < y_max ; y ++ ) { if ( ! acc [ y ] ) { acc [ y ] = [ ] ; } for ( x = x_min ; x < x_max ; x ++ ) { acc [ y ] [ x ] = pixelValue ; } } return acc ; } , currentPixels || [ ] ) ; }
Given a 2D array representing the screen and a list of rectangular dimension tuples, turn on the screen pixels that match the dimensions.
Given a 2D array representing the screen and a list of rectangular dimension tuples turn on the screen pixels that match the dimensions .
// Object is off-screen // We fill all pixels of this resource with a true // this is needed to correctly account for overlapping resources