/**
 * @author Bruno
 */
$(document).ready(
	function()
	{
		disegnaFigura = function()
		{
			var $canvas, myx, myy, w, h, r, c, o;
			$canvas = $("canvas");
			myx = $('#pos_x').val();
			myy = $('#pos_y').val();
			w = Math.floor(Math.random() * 100);
			h = Math.floor(Math.random() * 100);
			r = Math.floor(Math.random() * 100);
			c = $('#colore_txt').val();
			o = $('#opacity_txt').val();
			switch ($('#forma_select').val())
			{
				case 'Quadrato':
					$canvas.drawRect(
						{
							fillStyle:c,
							x:myx, 
							y:myy,
							width:w,
							height:w,
							fromCenter:false,
							opacity:o
						}
					);
				break;
				case 'Rettangolo':
					$canvas.drawRect(
						{
							fillStyle:c,
							x:myx, 
							y:myy,
							width:w,
							height:y,
							fromCenter:false,
							opacity:o
						}
					);
				break;
				case 'Cerchio':
					$canvas.drawArc(
						{
							fillStyle:c,
							x:myx, 
							y:myy,
							start:0,
							end:Math.PI * 2,
							fromCenter:false,
							opacity:o
						}
					);
				break;
			}
		}
		$('#disegna_btn').click(disegnaFigura);
		$('#clear_btn').click(function(){$('canvas').clearCanvas()});
	}
);
