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.

1

Friday, April 29th 2016, 2:55am

Help! feel lost about the official documents.

Hi, there?
Today i looked into the anihotspots.xml and felt confused of the first definition of <action>, namely the “do_crop_animation” action. From the official documents, i haven’t found any hints about “registerattribute”, ”imagewidth”,”imageheight”,”loaded”,”onlastframe()”. Could you help me to explain the usages of these functions and variables. Also, i totally felt lost about the usage of “BOR” in the line of “registerattribute(xframes, calc((imagewidth / %1) BOR 0));”. What does it mean? Thanks.

2

Friday, April 29th 2016, 8:38am

Hi,

yes, this one action is a more trickier one ;-).
One reason was it was designed to be more universally usable, e.g. for hotspot and layer elements, and to correct slightly wrong inputs.

The 'registerattribute' function is from the plugin-api, but it's also callable and usable from xml:
http://krpano.com/docu/plugininterface/#registerattribute

It basically directly adds an new attribute to the current 'caller' object (which can be either a hotspot or a layer). An other way would be using - set(layer[get(name)].attribute, value); - but there it would be necessary to differ between hotspots and layers.


The 'imagewidth', 'imageheight' and 'loaded' attributes are normal ones - see here in the documentation:
http://krpano.com/docu/xml/#hotspot.imagewidth
http://krpano.com/docu/xml/#hotspot.loaded


The 'onlastframe' event is a custom one from the 'do_crop_animation' action. The actions checks if at the given hotspot (or layer) an 'onlastframe' attribute is defined, and when yes, it calls it on the last frame of the animation. E.g. the 'explosion' hotspot changes it's location every time in this case.


That 'BOR' means 'bit-wise OR' - see here the expressions documentation:
http://krpano.com/docu/actions/#expressions

And using 'value BOR 0' is a trick to convert an number to an integer - that means removing the decimal places (like rounding down). Otherwise there could be eventuality a remainder when using (wrongly) an image size that is not fully dividable by the frame size.

Instead of:

Source code

1
registerattribute(xframes, calc((imagewidth / %1) BOR 0));
it would be also possible to write the code this way:

Source code

1
2
3
div(tmp, imagewidth, %1);               // do the division
Math.floor(tmp);                        // round down to remove an potential remainder 
registerattribute(xframes, get(tmp));   // register the attribute with that value
but that's not necessarily better ;-).

Best regards,
Klaus

3

Friday, April 29th 2016, 9:04am

Thanks, Klaus

Many Thanks to my friend, Klaus. Welcome to visit China! I will treat u with delicious Chinese food. *thumbsup*