You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

michel

Professional

  • "michel" started this thread

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

1

Tuesday, June 22nd 2010, 1:38am

Unexpected results in trying to set custom settings for the area.

Hi Klaus,

I got strange results in trying to set custom settings for the area.
I try to set the area.x to 50% and the area.with to half of stagewidth (the rest of the stage width)...
Like this:

Source code

1
2
set(area.x,50%);
sub(area.width,stagewidth,area.pixelx);

But, in this code, the resulting area is not as I expect:

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
<krpano version="1.0.8" onstart="showlog(); area_settings();" > 

	<view fov="120" fovtype="DFOV" />

	<preview type="grid(cube, 20, 20, 200, 0xCCCCCC, 0xFFFFFF, 0x000000)" details="12" />

	<events onresize="trace_area(from_onresize);" />	
			
	<action name="area_settings">
		trace('-- call to area_settings() --');
		set(area.x,50%);
		sub(area.width,stagewidth,area.pixelx);
		trace_area(from_area_settings);
	</action>
			
	<action name="trace_area">
		trace('-- trace_area %1 --');
		trace('area.x = ',area.x);
		trace('area.pixelx = ',area.pixelx);
		trace('area.width = ',area.width);
		trace('area.pixelwidth = ',area.pixelwidth);
		trace('stagewidth = ',stagewidth);
	</action>

</krpano>

with this code, the area is displayed correctly beginning at the middle of the screen but the width is displayed only half (the other half it is out of the screen).
The resulting trace are:

Quoted

INFO: krpano 1.0.8.11 (build 2010-05-31)
INFO: Flashplayer WIN 10,1,53,64 PlugIn
WARNING: not local trusted - ExternalInterface disabled!
INFO: -- call to area_settings() --
INFO: -- trace_area from_area_settings --
INFO: area.x = 50%
INFO: area.pixelx = 0
INFO: area.width = 1024
INFO: area.pixelwidth = 1024
INFO: stagewidth = 1024
INFO: -- trace_area from_onresize --
INFO: area.x = 50%
INFO: area.pixelx = 512
INFO: area.width = 1024
INFO: area.pixelwidth = 1024
INFO: stagewidth = 1024
Adding in line 12 a wait(0); inside the action that sets the area:

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
<krpano version="1.0.8" onstart="showlog(); area_settings();" > 

	<view fov="120" fovtype="DFOV" />

	<preview type="grid(cube, 20, 20, 200, 0xCCCCCC, 0xFFFFFF, 0x000000)" details="12" />

	<events onresize="trace_area(from_onresize);" />	
			
	<action name="area_settings">
		trace('-- call to area_settings() --');
		set(area.x,50%);
		wait(0);
		sub(area.width,stagewidth,area.pixelx);
		trace_area(from_area_settings);
	</action>
			
	<action name="trace_area">
		trace('-- trace_area %1 --');
		trace('area.x = ',area.x);
		trace('area.pixelx = ',area.pixelx);
		trace('area.width = ',area.width);
		trace('area.pixelwidth = ',area.pixelwidth);
		trace('stagewidth = ',stagewidth);
	</action>

</krpano>

Using this wait(0); the area displays correctly beginning at the middle of the screen and the width is egal to half of the stagewidth as expected.
And the resulting trace are:

Quoted

INFO: krpano 1.0.8.11 (build 2010-05-31)
INFO: Flashplayer WIN 10,1,53,64 PlugIn
WARNING: not local trusted - ExternalInterface disabled!
INFO: -- call to area_settings() --
INFO: -- trace_area from_area_settings --
INFO: area.x = 50%
INFO: area.pixelx = 512
INFO: area.width = 512
INFO: area.pixelwidth = 1024
INFO: stagewidth = 1024
INFO: -- trace_area from_onresize --
INFO: area.x = 50%
INFO: area.pixelx = 512
INFO: area.width = 512
INFO: area.pixelwidth = 1024
INFO: stagewidth = 1024
INFO: -- trace_area from_onresize --
INFO: area.x = 50%
INFO: area.pixelx = 512
INFO: area.width = 512
INFO: area.pixelwidth = 512
INFO: stagewidth = 1024
only at the end of the trace, the area variables are as expected...
*question* *question* *question* I am doing something wrong *confused*

SAlut.

2

Tuesday, June 22nd 2010, 9:38am

Hi,

the "area.pixel*" values were not updated immediately,
they will be updated during the next screen refresh (or during a browser resize) and then also the onresize event will be called,
(note - inside then onresize event the area values can be adjusted/changed again, but then there will be no second onresize event),

best regards,
Klaus

Posts: 1,852

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

3

Saturday, March 19th 2011, 6:23pm

Hi,

the "area.pixel*" values were not updated immediately,
they will be updated during the next screen refresh (or during a browser resize) and then also the onresize event will be called,
(note - inside then onresize event the area values can be adjusted/changed again, but then there will be no second onresize event),

best regards,
Klaus
There seems to be a bug with the area variables.
Using the trace plugin, you can see when using window maximize/minimize the calculated values are for the previous state, not the current state.
Is there a way to force an update to these variables onresize?
The stage variables are fine.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

4

Wednesday, March 23rd 2011, 9:59am

Hi,
There seems to be a bug with the area variables.
which bug?


Is there a way to force an update to these variables onresize?
in the onresize event itself, the values are already updated,
but when changing the the area values inside the onresize event again there is no second onresize event,
a wait(0) or delayedcall(0,..) could help to wait until the screen has been redrawn and the pixel values are updated again, but when changing the area values inside the onresize event it would be better the calculate all values manually, e.g. %50 width would mean mul(yourwidth, stagewidth, 0.5);

best regards,
Klaus

Posts: 1,852

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

5

Wednesday, March 23rd 2011, 9:10pm

Well in the examples where you are tracing the area.pixelwidth etc.
Dragging the window shows the area pixel width correctly.
However, on using the browser windows maximize and minimize, the trace shows incorrectly.

For instance a 400px window then maximize shows area.pixelwidth = 400px not 1920
Then when you unmaximize it will show 1920.
Yes, manual calculations aren't so terrible HOWEVER, it can be difficult to calculated heights that have been removed do to the additions of browser toolbars etc.


So for a real world example, if you have a panorama set to occupy an area 80% width and height of the stage, and you want a graphic element 75% height of the area, and the user maximizes the screen, your element will be calculated wrong using area.pixelheight which is one step behind.
Or I'm probably mis-understanding proper usage of area.pixel[]. Im assuming its the area of space where the panorama is drawn.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

Posts: 1,852

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

6

Wednesday, March 23rd 2011, 9:16pm

using delayedcall(0, to get the area.sizes on in onresize event works a treat.
Good FYI!
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

Similar threads