Sie sind nicht angemeldet.

1

Freitag, 29. April 2016, 02:55

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

Freitag, 29. April 2016, 08:38

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:

Quellcode

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

Quellcode

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

Freitag, 29. April 2016, 09:04

Thanks, Klaus

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