Functions / level
level(n)
level( )
level(int n)

level( )
return: current level of object
Code
<script type="text/javascript">
	function start_1(idCanvas)
	{
		alert(jc('#myCircle_1').level());
	}

	function stop_1(idCanvas)
	{
		jc.clear(idCanvas);
		onload_1('canvas_1');
	}
	
	function onload_1(idCanvas)
	{
		jc.start(idCanvas,true);
		var fillStyle = "rgb("+255+", "+0+", "+0+")";
		var radius=40;
		jc.circle(80,80,radius,fillStyle,1);
		fillStyle = "rgb("+0+", "+0+", "+255+")";
		jc.circle(140,70,radius,fillStyle,1)
			.id('myCircle_1');
		fillStyle = "rgb("+0+", "+255+", "+0+")";
		jc.circle(100,120,radius,fillStyle,1);
	}
</script>
<canvas id="canvas_1" width="250px" height="265px"></canvas>
View
level(int n)
return: object
Allows you to set level of object or layer.

Layers and objects have a level, and are drawn from smaller to higher level on the canvas

  • level can be any number (even negative)
  • levels don't need to be successive (-5, 12, 13, 14, 1890)
  • when created, the first object has a default level of 0
  • when created, all subsequent objects have a default level value of max level +1
  • calling .level('top') on a object gives it a level of max level +1
  • calling .level('bottom') on a object gives it a level of min level - 1
  • objects can have the same level; in this case there is no guarantee order between them.
Code
<script type="text/javascript">
	function start_2(idCanvas)
	{
		var circle=jc('#myCircle_2');
		circle.level(circle.level()-1);
	}
	function stop_2(idCanvas)
	{
		jc.clear(idCanvas);
		onload_2('canvas_2');
	}
	
	function onload_2(idCanvas)
	{
		jc.start(idCanvas,true);
		var fillStyle = "rgb("+255+", "+0+", "+0+")";
		var radius=40;
		jc.circle(80,80,radius,fillStyle,1);
		fillStyle = "rgb("+0+", "+0+", "+255+")";
		jc.circle(140,70,radius,fillStyle,1)
			.id('myCircle_2');
		fillStyle = "rgb("+0+", "+255+", "+0+")";
		jc.circle(100,120,radius,fillStyle,1);
	}
</script>
<canvas id="canvas_2" width="250px" height="265px"></canvas>
View