String Length

cwilms's picture

I have one, I hope last question, to finish this project I am working on.

I have about 200-300 strings varying in character lengths (peoples First and Last names) being sent to a Kineme Vector with String node. Because the character length can vary so dramatically I need to be able to make a mathematical expression that can scale the X value of the Vector image based on the string length character count. Basically reducing the character width by a sliding scale if the character length is above say 10 characters but not scaling it if the character length is below 10 characters. The height is already set and will not be changing.

I am having trouble thinking of an math expression that can do this. Any ideas on how I might write this?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

jersmi's picture
Re: String Length

Maybe try something like:

To reduce scale as number of characters gets larger, use Vector Transform after Vector with String with this: length > 10 ? scale * (1 - (length / (length + 1))) : 1, where string = String Length.

To reduce font size: length > 10 ? size * (scale * (1 - (length / (length + 1)))) : size, where length = String Length and size = Font Size. Scale ends up being something like 11.

cwilms's picture
Re: String Length

That first Math Expression worked perfectly. Thanks jersmi!!

cwilms's picture
Re: String Length

oops duplicate post.

jrs's picture
Re: String Length

Another way you can do this is with the interpolation patch you feed the string length into the patch time, use the duration as the max string length and then use the start and end values as the min and max widths. The one (small) advantage of this is you can use the different interpolation methods to create spacing effects, more of a use with positioning than widths though.