/**
 * @author Bruno
 */
$(document).ready(function() {
	var disegna = function()
	{
		var cx, cy, w, h, o, shape;
		cx = Math.floor(Math.random() * 800);
		cy = Math.floor(Math.random() * 350);
		w = 10 + (Math.floor(Math.random() * 190));
		h = 10 + (Math.floor(Math.random() * 190));
		r = Math.round(w/2);
		o = Math.random();
		shape = $('#sel_shape').val();
		
		switch (shape)
		{
			case 'Quadrato':
				$('canvas').drawRect(
					{
						x:cx,
						y:cy,
						width:w,
						height:w,
						fillStyle:"#ff6600",
						opacity:o,
						fromCenter: false
					});
			break;
			case 'Rettangolo':
				$('canvas').drawRect(
					{
						x:cx,
						y:cy,
						width:w,
						height:h,
						fillStyle:"#ffaa00",
						opacity:o,
						fromCenter: false
					}
				)			
			break;
			case 'Cerchio':
				$('canvas').drawArc(
					{
						x:cx,
						y:cy,
						radius:r,
						fillStyle:"#666",
						opacity:o
					}
				)
			break;
		}
	}
	$('#disegna_btn').click(disegna);
	$('#clear_btn').click(function(){
		$('canvas').clearCanvas();
	})
	$('button').button();
});
