Sure, there is a way to find automatically the ratio of height and width in the html using javascript ( I have not tried to find how
Quoted
by the way: is there a method to scale the preview by percent in the html, and find automatically the ratio of height and width?
, perhaps later )...
... And I made a code that partially match with your needs without using extra html code like table and div style, only with features of Krpano...|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
<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"
/>
<!-- ONRESIZE event where the actions needed to set the area and the border are called -->
<events onresize="define_area_size(500,200,30); set_border()" />
<!-- 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(); );
trace("stagewidth = ",stagewidth);
trace("stageheight = ",stageheight);
trace("aspect = ",aspect);
trace("dest_area_x = ",dest_area_x);
trace("dest_area_width = ",dest_area_width);
trace("dest_area_height = ",dest_area_height);
trace("dest_area_y = ",dest_area_y);
</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>
</krpano>
|
Thank you
Quoted
thanks alot for your thoughts! you are genius!
but I am only an Krpano enthusiast user like you
... The only genius here is KLAUS
do not you think so ?I have modified the code to take in account your needs... like this:
Quoted
the only thing is: when using the fullscreen button, it stays in the same borders...
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
<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();"
/>
<!-- 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(); );
trace("stagewidth = ",stagewidth);
trace("stageheight = ",stageheight);
trace("aspect = ",aspect);
trace("dest_area_x = ",dest_area_x);
trace("dest_area_width = ",dest_area_width);
trace("dest_area_height = ",dest_area_height);
trace("dest_area_y = ",dest_area_y);
</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(events.onresize,);
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>
|
....
... You have set the image width and height as 500 and 150... If I am not on mistake, on your first attempt you have set the <div> width and height to 960 and 320... so the image aspect ratio is 3:1.|
|
Source code |
1 2 3 |
define_area_size(960,320,30); or define_area_size(3,1,30); |
.