Graphics

 View Only
  • 1.  centering a box vertically

    Posted 08-19-2019 20:49

     

    Hi. I have a text box that is limited to word wrap at a certain point. I'm feeding it from a datalinq source.
    The text box can have 1, 2 or 3 lines. The text box is over a graphic box and I want the box to remain centered vertically in that box. I have tried t to set the y pivot point to the center of the single line and using visual logic get it to shift based on the height of the bounding box but it's not staying centered. I'm really new to visual logic. I've looked through the forum but people have more parameters than i have and I can't sort it out.



  • 2.  RE: centering a box vertically

    Posted 08-20-2019 02:17

    While I have not done this with a box, I have many times had to keep a piece of text with wordwrap centered within a box, so the idea here should be similar.

     

    Basically, you DO want the Bounding Box Height Scaled node to be feeding the Y position node of the box, but you will need to put a Divide node between them with a value of /2, and then an offset in that order between the text bounding box and the y position of your box.  The value of the offset can be played with until you get your desired position, an then you should be off to the races.

     

    Here's a look at this logic in one or my current scenes:

     

    Just substitute your graphic box for the body text Position Y in that example, and dial in the value to taste.  And if the box moves in the direction opposite from what you would expect, just put a Multiply node with a -1 value between the Division and Offset

     

    Hope this helps!


    #XPression


  • 3.  RE: centering a box vertically

    Posted 08-20-2019 02:45

    I sort of brute force this because getting a pivot point centered on text dynamically always seems to be a matter of trial and error. I do the following:

    1. Use the align tool to align 1-line text vertically to background box
    2. Drag your textbox as a child of your quad and record the number also record the bounding box height within visual logic
    3. Repeat steps for 2 and 3-line text boxes while recording each number when parented
    4. Take those values and hardcode them into 3 value nodes in Visual Logic
    5. Use an add node to cumulatively count the True values (1s) from the greater than nodes (I set the value to +1 in the event of any trailing decimals)

    The above example was done with a quad with a height of 450px, centered to 960x540. The font was the default Arial 62pt with no other settings adjusted. The advantage of taking the child values is in case you have to move the quad, this way you don't have to go through the process again. For what it's worth, those values would be the reverse if you parented your quad to your text box and wanted to reset the relative PosY of your box.


    #XPression


  • 4.  RE: centering a box vertically

    Posted 08-20-2019 20:42

    Willie Fraser you rock!!!!... I'm sure everyone else does as well.. but that worked... or at least close enough for folk.  I think the bounding box scaled as oppose to bounding box height did the trick... and the offset.. I was using value.. anyhoo.. thanks loads... 


    #XPression


  • 5.  RE: centering a box vertically

    Posted 08-20-2019 20:53

    Yay!  Happy to have been able to help.


    #XPression