Hi KLAUS,
Is there a native Krpano function to reset the <area> to the stage width and height (as it is by default before setting an <area>)
In trying to answer a thread from machart (new approach for widescreen presentation), I was needing to reset the <area>. So I have tried something like reset(area) and others but without succes.
I have found a way that works, using the onresize event for call an action that sets the <area> to match the stage but I am not sure that is the best way to do.
Here is an example code I used to test:
Code
<krpano onstart="showtext(Try to resize the browser, infostyle);">
<!-- use only a grid preview pano to save download space ;-) -->
<preview type="grid(cube,50,50,400,0xCCCCCC,0x999999,0xFFFFFF);" details="16" />
<view hlookat="0" fovmin="80" fovmin="50" fovmax="150" maxpixelzoom="off" />
<textstyle name="infostyle"
origin="center" edge="center" textalign="center" background="false" border="false"
fontsize="40" textcolor="0xFFFFFF" bold="false" effect="glow(0xFFFFFF,0.7,4,2);glow(0x000000,1,4,2);dropshadow(3,45,0x000000,2,0.6);"
showtime="5" fadetime="1.0"
/>
<!-- Events where the actions needed to set the area and the border are called -->
<events onresize="define_area_size(500,200,30); set_border()"
onenterfullscreen="reset_area_size();"
onexitfullscreen="back_area_size(); events.onresize();"
/>
<style name="buttonstyle"
url="%SWFPATH%/plugins/textfield.swf" children="false"
width="150" height="22"
css="p{color:#000000; font-family:Arial; font-weight:bold; font-size:14; margin-left:5; margin-right:5; text-align:center; }"
backgroundcolor="0xFFFFFF" roundedge="5" shadow="1" borderwidth="0" glow="4" glowcolor="0xFFFFFF"
visible="false"
onover="tween(alpha,0.7,distance(0.3,0.2));"
onout="tween(alpha,1.0,distance(0.3,0.2));"
onloaded="set(alpha,0);set(textblur,15);set(blur,15); set(visible,true); tween(alpha,1,0.3); tween(textblur,0,0.3); tween(blur,0,0.3);"
/>
<plugin name="set_area" keep="true" style="buttonstyle"
html="[p]set_area[/p]"
align="bottom" x="-120" y="25"
onclick="back_area_size(); events.onresize();"
/>
<plugin name="reset_area" keep="true" style="buttonstyle"
html="[p]reset_area[/p]"
align="bottom" x="120" y="25"
onclick="set(events.onresize,'reset_area_size()'); events.onresize();"
/>
<!-- border -->
<plugin name="border_top" url="border_x2.png" enabled="false" align="lefttop" edge="lefttop" />
<plugin name="border_bottom" url="border_x2.png" enabled="false" align="leftbottom" edge="leftbottom" />
<plugin name="border_left" url="border_x2.png" enabled="false" align="lefttop" edge="lefttop" />
<plugin name="border_right" url="border_x2.png" enabled="false" align="righttop" edge="righttop" />
<!-- action to set the border of the area -->
<action name="set_border">
set(plugin[border_top].width,get(area.width));
set(plugin[border_bottom].width,get(area.width));
set(plugin[border_left].height,get(area.height));
set(plugin[border_right].height,get(area.height));
</action>
<!-- actions to set the area -->
<!-- Example of use: -->
<!-- define_area_size(500,200,30); -->
<!-- there is 3 parameters: -->
<!-- %1 = image width -- ex: 500 -->
<!-- %2 = image height -- ex: 200 -->
<!-- %3 = margin -- ex: 30 -->
<action name="define_area_size">
trace(%1_%2_%3);
div(aspect,%1,%2);
set(dest_area_x,%3);
mul(temp_val,dest_area_x,2); sub(dest_area_width,stagewidth,get(temp_val));
div(dest_area_height,dest_area_width,aspect);
sub(temp_val,stageheight,dest_area_height); div(dest_area_y,get(temp_val),2);
if(dest_area_y LT dest_area_x, set(dest_area_y,%3);
mul(temp_val,dest_area_y,2); sub(dest_area_height,stageheight,get(temp_val));
mul(dest_area_width,dest_area_height,aspect);
sub(temp_val,stagewidth,dest_area_width); div(dest_area_x,get(temp_val),2);
set_area_size(); , set_area_size(); );
</action>
<!-- actions to set the area -->
<action name="set_area_size">
copy(area.x, dest_area_x);
copy(area.y, dest_area_y);
copy(area.width, dest_area_width);
copy(area.height, dest_area_height);
</action>
<!-- actions to reset the area -->
<action name="reset_area_size">
set(area.x, 0);
set(area.y, 0);
set(area.width, get(stagewidth));
set(area.height, get(stageheight));
set(plugin[border_top].visible,false);
set(plugin[border_bottom].visible,false);
set(plugin[border_left].visible,false);
set(plugin[border_right].visible,false);
</action>
<action name="back_area_size">
set(events.onresize,'define_area_size(500,200,30); set_border()');
set(plugin[border_top].visible,true);
set(plugin[border_bottom].visible,true);
set(plugin[border_left].visible,true);
set(plugin[border_right].visible,true);
</action>
</krpano>
Display More
Is there a better way to do ? A native function ?
SAlut.