Categories
krpano

Area Margin

This script allows you to set the different margins of an area. It then scales the area to the remaining width and height.

	<events onresize="setMargin(10,10,10,10);" />
	<!-- setMargin(leftmargin,topmargin,bottommargin,rightmargin); -->
	<action name="setMargin">
		<!-- calculate remaining width. stagewidth - marginleft - marginright = area width -->
		sub(tmp1, stagewidth, %1); sub(tmp2, tmp1, %4); copy(area.width, tmp2);
		<!-- calculate remaining height. stageheight - margintop - marginbottom = area height -->
		sub(tmp3, stageheight, %2); sub(tmp4, tmp3, %3); copy(area.height, tmp4);
		<!--move the area-->
		set(area.x, %1); set(area.y, %2);
	</action>

This script allows for a fixed width/height area in krpano. The area is then posistioned in the center of the screen.

<events onresize="define_area_size(1008,571);" />

	<action name="define_area_size">
		div(halfstagewidth, stagewidth, 2); div(halfareawidth, %1, 2); sub(dest_area_x, halfstagewidth, halfareawidth);
		copy(area.x, dest_area_x);
		div(halfstageheight, stageheight, 2); div(halfareaheight, %2, 2); sub(dest_area_y, halfstageheight, halfareaheight);
		copy(area.y, dest_area_y);
		set(area.width, %1);
		set(area.height, %2);
	</action>

Leave a Reply

Your email address will not be published. Required fields are marked *