function draw_textbox(text, xCenter, yCenter, options)
{
	var defaults = {
		x_margin: 5,
		y_margin: 5,
		backColor: 'white',
		outlineColor: 'black',
		textFrontColor: 'black',
		textBackColor: 'black',
		font: '16px Arial',
		centered: true
	};
	var tb = Matter.Common.extend(defaults, options);

	// Split input into lines
	var lines = text.split('\n');
	
	// Calculate width / height
	ctx.font = tb.font;
	var lineh = pixiGetFontHeight(ctx.font) + tb.y_margin;
	var h = tb.height || (lineh * lines.length + tb.y_margin);
	var w = 0;
	if (tb.width)
		w = tb.width;
	else
	{
		for (var i in lines)
		{
			var tw = ctx.measureText(lines[i]).width;
			if (tw > w)
				w = tw;
		}
		w += 2 * tb.x_margin;
	}
	var x, y;
	if (tb.centered == true)
		x = xCenter - w/2, y = yCenter - h/2;
	else
		x = xCenter, y = yCenter;
	
	ctx.fillStyle = tb.backColor; ctx.strokeStyle = tb.outlineColor;
	ctx.fillRect(x, y, w, h);
	ctx.strokeRect(x, y, w, h);
	
	ctx.textAlign = 'left'; ctx.textBaseline = 'top';
	x += tb.x_margin;
	y += tb.y_margin;
	ctx.fillStyle = tb.textFrontColor;
	ctx.shadowColor = tb.textBackColor;
	ctx.shadowOffsetX = 1;
	ctx.shadowOffsetY = 1;
	ctx.shadowBlur = 3;
	for (i in lines)
	{
		ctx.fillText(lines[i], x, y);
		y += lineh;
	}
	ctx.shadowColor = 'rgba(0,0,0,0)';
}
// Draws a text box centered at (xCenter, yCenter)
Draws a text box centered at (xCenter, yCenter)
Draws a text box centered at ( xCenter yCenter )
function draw_textbox(text, xCenter, yCenter, options)
{
	var defaults = {
		x_margin: 5,
		y_margin: 5,
		backColor: 'white',
		outlineColor: 'black',
		textFrontColor: 'black',
		textBackColor: 'black',
		font: '16px Arial',
		centered: true
	};
	var tb = Matter.Common.extend(defaults, options);
	var lines = text.split('\n');
	ctx.font = tb.font;
	var lineh = pixiGetFontHeight(ctx.font) + tb.y_margin;
	var h = tb.height || (lineh * lines.length + tb.y_margin);
	var w = 0;
	if (tb.width)
		w = tb.width;
	else
	{
		for (var i in lines)
		{
			var tw = ctx.measureText(lines[i]).width;
			if (tw > w)
				w = tw;
		}
		w += 2 * tb.x_margin;
	}
	var x, y;
	if (tb.centered == true)
		x = xCenter - w/2, y = yCenter - h/2;
	else
		x = xCenter, y = yCenter;
	ctx.fillStyle = tb.backColor; ctx.strokeStyle = tb.outlineColor;
	ctx.fillRect(x, y, w, h);
	ctx.strokeRect(x, y, w, h);
	ctx.textAlign = 'left'; ctx.textBaseline = 'top';
	x += tb.x_margin;
	y += tb.y_margin;
	ctx.fillStyle = tb.textFrontColor;
	ctx.shadowColor = tb.textBackColor;
	ctx.shadowOffsetX = 1;
	ctx.shadowOffsetY = 1;
	ctx.shadowBlur = 3;
	for (i in lines)
	{
		ctx.fillText(lines[i], x, y);
		y += lineh;
	}
	ctx.shadowColor = 'rgba(0,0,0,0)';
}
function draw_textbox ( text , xCenter , yCenter , options ) { var defaults = { x_margin : 5 , y_margin : 5 , backColor : 'white' , outlineColor : 'black' , textFrontColor : 'black' , textBackColor : 'black' , font : '16px Arial' , centered : true } ; var tb = Matter . Common . extend ( defaults , options ) ; var lines = text . split ( '\n' ) ; ctx . font = tb . font ; var lineh = pixiGetFontHeight ( ctx . font ) + tb . y_margin ; var h = tb . height || ( lineh * lines . length + tb . y_margin ) ; var w = 0 ; if ( tb . width ) w = tb . width ; else { for ( var i in lines ) { var tw = ctx . measureText ( lines [ i ] ) . width ; if ( tw > w ) w = tw ; } w += 2 * tb . x_margin ; } var x , y ; if ( tb . centered == true ) x = xCenter - w / 2 , y = yCenter - h / 2 ; else x = xCenter , y = yCenter ; ctx . fillStyle = tb . backColor ; ctx . strokeStyle = tb . outlineColor ; ctx . fillRect ( x , y , w , h ) ; ctx . strokeRect ( x , y , w , h ) ; ctx . textAlign = 'left' ; ctx . textBaseline = 'top' ; x += tb . x_margin ; y += tb . y_margin ; ctx . fillStyle = tb . textFrontColor ; ctx . shadowColor = tb . textBackColor ; ctx . shadowOffsetX = 1 ; ctx . shadowOffsetY = 1 ; ctx . shadowBlur = 3 ; for ( i in lines ) { ctx . fillText ( lines [ i ] , x , y ) ; y += lineh ; } ctx . shadowColor = 'rgba(0,0,0,0)' ; }
Draws a text box centered at (xCenter, yCenter)
Draws a text box centered at ( xCenter yCenter )
// Split input into lines // Calculate width / height