FSXA draw dynamic rectangle in opposite direction

#1
Hi XML gurus,
Im struggling with this animation and decided to post here see wether somebody can give me an idea how to do it.
I want an animation, where a rectangle is dynamically draw starting from a width,height of (0,0) to (20,12), but it has to grow from both side (Left and right).

To have an idea what I want to achieve look at this video (min. 4.59 -5.00) where the baro min box apears on the copilots PFD:

Now I have it partialy working with this code snipet from my PFD but the rectangle animates from left to right and I need it to be both side like in the video.

Code:
        (* Piece in my update section that Draws the  Baro Minimun box regtangle *)
        (A:Decision height, feet) (A:Decision height, feet) 100 + (A:Radio height, feet) rng if{ (L:tel,number) ++ (>L:tel,number) } els{ 0 (>L:tel,number)    } 
      
      (* Piece in the PFD guage that take cares of the rectangle *)
      <Element>
        <Visible>(A:SIM ON GROUND, bool) 0 == if{ (A:Decision height, feet) (A:Decision height, feet) 100 + (A:Radio height, feet) rng } </Visible>
          <Position X="65" Y="55"/>
          <Rectangle Width="20" Height="12" Bright="Yes" FillColor="black">
            <WidthCode>(L:tel,number) 2 / </WidthCode>
            <HeightCode>(L:tel,number) 3.6 / </HeightCode>
          </Rectangle>
      </Element>
Don't put much attention on my coding my way of programming in XML is somewhat goofy but it works. I'm dividing (L:tel, number) just to create some delay since I use simulator frequency for animation 1/18.

Any idea how i can achieve what is seen in the video using a more efficient code in XML?
thanks.
Adino
 

Luka

Resource contributor
#2
Try to add a Shift code. With Shift (X and Y) and Width/HeightCode you should be able to have full control of the rectangle.
 
#3
Hi Luka,
Thank you for pointing me in the right direction, However I have never seen a code snippet with the shift code being used together with the rectangle code I have no idea how I would combine those two to achieve the animation. Any gauge (pseudo) code or snippet that can point me into the right direction?
 

Luka

Resource contributor
#4
Code:
<Element>
    <Visible>(A:SIM ON GROUND, bool) 0 == if{ (A:Decision height, feet) (A:Decision height, feet) 100 + (A:Radio height, feet) rng }</Visible>
    <Position X="65" Y="55"/>
    <Rectangle Width="20" Height="12" Bright="Yes" FillColor="black">
        <WidthCode>(L:tel,number) 2 / </WidthCode>
        <HeightCode>(L:tel,number) 3.6 / </HeightCode>
    </Rectangle>
    <Shift><Value>(L:tel,number) 2 / 20 min 2 /</Value><Scale X="-1"/></Shift>
    <Shift><Value>(L:tel,number) 3.6 / 12 min 2 /</Value><Scale Y="-1"/></Shift>
</Element>
 
#5
Hi Luka,
Brilliant! worked like a charm! I never knew you could use the code that way, it opens a world of posibilities for me now.
Thank you so much awesome knowledge around here.
 
Top