Graphics

 View Only
  • 1.  Visual Logic: adjust text depending on size of picture and amount of text

    Posted 06-23-2019 01:38

    Hi all,

    This is actually a repost from a question I asked about two years ago, but which didn't found an answer then, but the problem has risen again and I hope that maybe this time an solution can be found.

     

    I'm building a scene where I have a picture and text side by side, the text is on the left and the picture is on the right.
    There are maximum sizes in place that can not be passed. So the maximum width is 1500px and the maximum height is 900px.
    The goal is to have the text adjust itself automatically to the size of the picture.

    Two examples to clarify:
    Case 1: the picture is 900px high and 1000px wide; => the text can be a maximum of 500px wide

    Case 2: the picture is 900px high and 600px width: => the text can be a maximum of 900px wide

    That is still quite easy to do with Visual Logic.
    Now comes the tricky part.

    I would like the text to be as big as possible inside the allowed dimensions.
    So for example if the text says "Nadal wins again", I would like the text to be much bigger than when the text says "Rafael Nadal writes
    history by becoming the first player to win Roland Garros 12 times in his career". See examples (https://pasteboard.co/IkFL5sM.png  & https://pasteboard.co/IkFLhv1.png ) to see what I mean.

    Now I have been playing around in Visual Logic trying to get this right using the WordWrap and scaling but I haven't managed to make it work flawlessy. It seems that the WordWrap is not always working the way it should. Sometimes it wraps with a wrong value. Then when I toggle it on and off, it adjusts itself but it's more often wrong than right. So to me this is not the right approach.

    Does anybody have an idea if there is another way to solve this?

    Thank you,
    Ken



  • 2.  RE: Visual Logic: adjust text depending on size of picture and amount of text

    Posted 07-08-2019 21:15

    Ken, do you have a screenshot of the visual logic you have so far?

    You may need to create another tab in visual logic so that the scaling and word wrap is done one after the other.


    #XPression


  • 3.  RE: Visual Logic: adjust text depending on size of picture and amount of text

    Posted 07-20-2019 19:39

    Hi!
    Even the task seems to be very simple, I couldn't find a shot way (it might be a good feature).
    As a steps we can have:
    - Assign image to other quad/material in order to find the dimensions.
    - Set the height to to 900px, get the weight and place the image in right
    - Fill the empty side of the frame with text
    - Based on the maximum font size and introduced title you can get the maximum area
    - Compare this area with empty area and calculate the equivalent width at maximum font size
    - Wrap the title and scale it to the right width
    - Auto squeeze title in the empty area width
    - Based on the width after auto squeeze, extract the scale ratio, verify if it fits in the empty area, scale and place the final title.
    Unfortunately, the Visual Logic is very large and is still not working correctly...
    This is my sample, but is not complete.

    Unfortunately, the Wrap function doesn't run well - sometimes it split the words without spaces and sometimes you get different results.
    In Visual Logic there is no order in steps and I decided to try all this in Scene Script :D
    On the community posts I found a short script to wrap the text.
    Without any knowledge in VB, but reading the help area and some other posts, step by step I reproduce the above schema in script.
    There are still some issues, but your titles/examples are looking fine.
    I didn't want to center the title in the frame, just keep it near the image, but you can do it if you want to.

    For evaluation you have the project in this link: http://s.go.ro/ln7yvqvc

    Have fun,
    Gabriel


    #XPression


  • 4.  RE: Visual Logic: adjust text depending on size of picture and amount of text

    Posted 07-21-2019 18:40

    And centered title.

    Link: http://s.go.ro/cu9jo24e


    #XPression