Auto resize rectangle size with text length

Q and A about functionality and how to solve a special task for your application.

Auto resize rectangle size with text length

Postby ahmedahmed1223 » 08 Jun 2017, 20:46

Hi there.
how i can link background rectangle width and length values with foreground text with random lengths?
and if the text have the shrink to fit effect how i can do this setup? :?:
ahmedahmed1223
 
Posts: 30
Joined: 07 Jan 2017, 14:02

Re: Auto resize rectangle size with text length

Postby ahmedahmed1223 » 09 Jun 2017, 10:04

Is there any ideas?
to explain my idea what i need to do something like this video
https://youtu.be/FgBzTSpg3A8?t=1m48s
ahmedahmed1223
 
Posts: 30
Joined: 07 Jan 2017, 14:02

Re: Auto resize rectangle size with text length

Postby Eric_RD » 09 Jun 2017, 15:20

quite easy ;)
Arranger: Y-Chain
Sum up Textbox heights -> Y
Max Textbox width -> X
done
Attachments
bg_textbox.vzs
(11.57 KiB) Downloaded 6 times
User avatar
Eric_RD
 
Posts: 54
Joined: 04 Jun 2014, 14:01

Re: Auto resize rectangle size with text length

Postby ahmedahmed1223 » 09 Jun 2017, 21:33

Thanks Eric_RD,
but what about shrink to fit effect usage case does this solution working in this workflow?
also if i need to scale the text using axis tool does this setup will work? :?:
ahmedahmed1223
 
Posts: 30
Joined: 07 Jan 2017, 14:02

Re: Auto resize rectangle size with text length

Postby ahmedahmed1223 » 12 Jun 2017, 12:40

Is there any other Ideas for this type of workflow?
ahmedahmed1223
 
Posts: 30
Joined: 07 Jan 2017, 14:02

Re: Auto resize rectangle size with text length

Postby Christian Krix Schmidt » 12 Jun 2017, 16:20

If you have Shrink2Fit, then you only have to check for each line whether the width of your text is shorter or longer than the Shrink2Fit width. That's a small expression that does the trick and can be added to each text line. If the text is longer than the shrink2fit width you assign that width as the size for your rectangle. and if the text size is smaller than the shrink2fit width, you assign the text size as the size for the rectangle.
Christian Krix Schmidt
 
Posts: 257
Joined: 18 Jan 2012, 11:36
Location: Dubai, United Arab Emirates

Re: Auto resize rectangle size with text length

Postby SamTheSwede » 12 Jun 2017, 16:59

This is how I usually do it, set a maxwidth in a "shrink to fit - node" then put all textwidths in a float array and figure out the highest number (max)

Good luck!

// Sam
Attachments
BGSCALER.vzs
(12.72 KiB) Downloaded 6 times
SamTheSwede
 
Posts: 73
Joined: 18 Jan 2012, 11:31

Re: Auto resize rectangle size with text length

Postby ahmedahmed1223 » 12 Jun 2017, 17:41

thanks SamTheSwede and Christian
i will try your suggestions and solutions.
ahmedahmed1223
 
Posts: 30
Joined: 07 Jan 2017, 14:02

Re: Auto resize rectangle size with text length

Postby ahmedahmed1223 » 14 Jun 2017, 10:45

Thanks all but is there any other solutions like and tool to get the final size of bounding box the text or the axis nodes?
also i am using right to left text is there any suggestions for this setup?
ahmedahmed1223
 
Posts: 30
Joined: 07 Jan 2017, 14:02

Re: Auto resize rectangle size with text length

Postby lerou » 14 Jun 2017, 11:46

Hi,

creating a bounding box around text is very easy. You can use the bounding box generated by the Text node - as already proposed.

Now if you use shrink 2 fit, that effect obviously changes the bounding box. It also has a parameter for the bounding box type - but it does not output the new bounding box. I'd suggest asking Ventuz support to implement that feature - unless I'm missing something.

For now, you'd need to manually calculate the scale and mimic the effect's behaviour. Here's an example.

cheers,
rou
Attachments
shrink2fit_manual.vza
(16.15 KiB) Downloaded 20 times
User avatar
lerou
 
Posts: 220
Joined: 06 Sep 2013, 07:14
Location: Hamburg, Germany

Next

Return to How to