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.

  • 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:
    https://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:
    https://krpano.com/docu/xml/#hotspot.imagewidth
    https://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:
    https://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:

    Code
    registerattribute(xframes, calc((imagewidth / %1) BOR 0));

    it would be also possible to write the code this way:

    Code
    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

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!