"Source value above minimum" in link behavior

Dear Motion community, I have a question about "source value above minimum" option in link behavior.


The manual says that when this option is selected in the "Apply Link When" dropdown menu "the Clamp Source Values Within Range checkbox as well as offset and minimum sliders for each setting associated with the source parameter appear at the bottom of the Behaviors Inspector." But in fact the minimum slider doesn't appear. The checkbox is there although.



Without this slider I cannot define the minimum value. Is there a way to do that?


One more question. Can I calculate the difference between two values in Motion and store/use the result somehow. For example - difference in width of two text layers and use the result in X Offset in link behavior? Anything close to math.max(a,b)? The main task is to use the biggest values of two (or more) parameters.


MacBook Pro

Posted on Nov 8, 2022 07:50 AM

Reply
Question marked as Top-ranking reply

Posted on Nov 8, 2022 10:45 AM

[This was long, so ... PART 1]


I'm going to start off by saying that this information is not documented anywhere — it is only what I've been able to figure out and so my explanation is solely based on observation and trying to "make sense" out of it.


Link is an incredibly powerful behavior but it can seem rather "quirky" from time to time as in this instance.


I started realizing quite awhile back that Link behaves according to "like parameters". By that I mean, if you have two rectangles and you link the same (like) parameter from one to the other, then you get the full complement of features that Link offers. If you cross over to an object that has different (behind the scenes) setups, then Link may or may not offer all of it's parameters for use.


When dealing with Text objects, much of what goes on behind the scenes is very much different than simple width/height measurements. There's things like Tracking, Kerning, Font, Styles, etc... and a whole collection of "metrics" (ascent, descent, etc.). A font's metrics start off in an imaginary (internally defined) grid that is applied to its destination. (I know this because I also design fonts). In the case of 3D Text, this internally defined grid helps establish its resolution (the more "intersections" in the grid, the more refined the 3D Text will be.)


So, back to your issue.


It looks like you have a Rectangle and some text and I'm guessing you want the Rectangle to be a minimum width and as Text is added to the Text object, you want that Rectangle to grow with the width of the text.


As you've discovered, when you Link them up for width, there's no minimum source value to use. There is a mismatch in parameters *even though* both deal with width.


Whenever you run into a condition like this, and this won't be the only time (believe me!) — the Numbers Generator is your friend.


Numbers is a generic number. It will match any kind of parameter (more or less — there are caveats). You will need to link objects values through a Numbers Value. What you have to watch out for is "resolution". Some parameters are represented by factors of 10 [and sometime π] different than they appear in the Motion interface (this will be one example).


A quick note about Numbers: it's default condition is to Animate (checkbox). You will never have access to the animated "value" of a Numbers generator. In order to use the Value parameter via Link, you must always uncheck Animate.


To set up something like the following:

Draw your Rectangle and make the width fit nicely with the text for say 4 characters. The text in the example below is emulating a "Type On" with a Sequence Text Behavior using Scale.X set to 0 and Spread set to 0. (End Offset used to control speed of "write on").


Set the Rectangle width to about 240 (or wide enough to fit 4 or so characters — I'll just stick with 240 for this example).


Add a Numbers Generator (you can turn off the visibility before going "live".) Turn off Animate and add a Link to the Value parameter.


To the Link Source Object, drag and drop the Text object and set the Source Parameter to Object Attributes > Size > Width.


To the Rectangle Shape Geometry Size Width parameter add another Link. For its Source Object, drag in the Numbers Generator and set the Compatible Parameters to Object.Numbers.Value.


Notice the Rectangle goes very wide. In this case, Numbers Value represents a "resolution" 10 times the Size value, so set the Link's Scale to 0.1 (to bring it back to "reality"). Set the Apply Link When Source value above minimum [which will appear in this circumstance] and set the Value Min to the original width of the Rectangle (about 240).


As you type in characters to the text object (or animate them as I did) the Rectangle will begin to widen once the minimum size of text reaches 240 pixels.





Similar questions

7 replies
Question marked as Top-ranking reply

Nov 8, 2022 10:45 AM in response to KirillSko

[This was long, so ... PART 1]


I'm going to start off by saying that this information is not documented anywhere — it is only what I've been able to figure out and so my explanation is solely based on observation and trying to "make sense" out of it.


Link is an incredibly powerful behavior but it can seem rather "quirky" from time to time as in this instance.


I started realizing quite awhile back that Link behaves according to "like parameters". By that I mean, if you have two rectangles and you link the same (like) parameter from one to the other, then you get the full complement of features that Link offers. If you cross over to an object that has different (behind the scenes) setups, then Link may or may not offer all of it's parameters for use.


When dealing with Text objects, much of what goes on behind the scenes is very much different than simple width/height measurements. There's things like Tracking, Kerning, Font, Styles, etc... and a whole collection of "metrics" (ascent, descent, etc.). A font's metrics start off in an imaginary (internally defined) grid that is applied to its destination. (I know this because I also design fonts). In the case of 3D Text, this internally defined grid helps establish its resolution (the more "intersections" in the grid, the more refined the 3D Text will be.)


So, back to your issue.


It looks like you have a Rectangle and some text and I'm guessing you want the Rectangle to be a minimum width and as Text is added to the Text object, you want that Rectangle to grow with the width of the text.


As you've discovered, when you Link them up for width, there's no minimum source value to use. There is a mismatch in parameters *even though* both deal with width.


Whenever you run into a condition like this, and this won't be the only time (believe me!) — the Numbers Generator is your friend.


Numbers is a generic number. It will match any kind of parameter (more or less — there are caveats). You will need to link objects values through a Numbers Value. What you have to watch out for is "resolution". Some parameters are represented by factors of 10 [and sometime π] different than they appear in the Motion interface (this will be one example).


A quick note about Numbers: it's default condition is to Animate (checkbox). You will never have access to the animated "value" of a Numbers generator. In order to use the Value parameter via Link, you must always uncheck Animate.


To set up something like the following:

Draw your Rectangle and make the width fit nicely with the text for say 4 characters. The text in the example below is emulating a "Type On" with a Sequence Text Behavior using Scale.X set to 0 and Spread set to 0. (End Offset used to control speed of "write on").


Set the Rectangle width to about 240 (or wide enough to fit 4 or so characters — I'll just stick with 240 for this example).


Add a Numbers Generator (you can turn off the visibility before going "live".) Turn off Animate and add a Link to the Value parameter.


To the Link Source Object, drag and drop the Text object and set the Source Parameter to Object Attributes > Size > Width.


To the Rectangle Shape Geometry Size Width parameter add another Link. For its Source Object, drag in the Numbers Generator and set the Compatible Parameters to Object.Numbers.Value.


Notice the Rectangle goes very wide. In this case, Numbers Value represents a "resolution" 10 times the Size value, so set the Link's Scale to 0.1 (to bring it back to "reality"). Set the Apply Link When Source value above minimum [which will appear in this circumstance] and set the Value Min to the original width of the Rectangle (about 240).


As you type in characters to the text object (or animate them as I did) the Rectangle will begin to widen once the minimum size of text reaches 240 pixels.





Nov 8, 2022 10:46 AM in response to fox_m

[ PART 2]


For full disclosure, to get the animation above, I used an Align To on the Rectangle to the Text. I had to Apply an Offset of about -15 X and 41 Y [this is dependent on the font size — I just wanted a little margin applied] and I also had to make an X Offset adjustment to the Link applied to the Numbers generator. I made that X Offset 22 (7 more than the -15 offset in Align To... again... adjustments like this will be based on which font it used... etc... You have to be flexible).



One more answer: Yes, you can save values! You can use any number of Numbers generators you need to chain calculations. The most simple is a Numbers generator Value with several Links applied to the same Value and set to Add to Source or Multiply by Source. The first one added can be Replace with Source OR the initial Value of Numbers can be the original start of calculations applied with Add or Multiply sources. Subtractions are done by setting Link Scale to -1.0. You can Min/Max values with a Clamp behavior as well as do some pretty remarkable things with Quantize. [Calculations are made in Layer order of Links from bottom up. ]


I've been pushing Numbers a bit (it's my preferred go to accumulator) but really, any "null object's" parameters can be used for most things (regard the warning about "like parameters" though). Numbers, however, has the extra added benefit of *on-screen display* while working out problems and is easily turned off at any time by unchecking its visibility in the Layer's List. The only real annoyance with Numbers is adjusting the Scale of calculations to match "real world" expectations and then having to convert again on the receiving side to make sure values match appropriately.


Doing Math in Motion is like being stranded in the middle of No Scripting land and all you have is a whole bunch of objects and behaviors lying around. What you can accomplish is really just a matter of how inventive you can be with the building blocks laying all around (and there are plenty!) You may think adding a bunch of Numbers Generators will slow things down, but in my experience, there is next to no hit whatsoever, especially if they're all visibly turned off. The one thing you cannot do is conditional/variable division. You have to be able to set up "divisions" beforehand as "inverses" to use in multiply, like 0.5, 0.3333, 0.25, 0.2, etc.... and I haven't been able to figure out how to apply a "logarithmic scale" from value to value.


I hope this was easy enough to understand! It's literally teaching Math in a different symbolic programming language that doesn't exactly jibe with anything you might have learned before.



Nov 9, 2022 03:21 AM in response to fox_m

This solution worked perfectly. So the problem, as I understood after fox_m's explanation, was the partial compatibility of the text width and the shape width. This non-perfect compatibility resulted in disabling the feature of min/max values. Using the number generator as an intermediary fixes this issue, you just need to adjust the scale to 0.1 and turn off animation.


Again, thanks a million for sharing this approach.


The next problem I'm facing is using this text linked shape as a mask for the text which defines the size of the rectangle. Once applied it freezes Motion completely.


My guess was that it happens because the mask source which is linked to the masked layer (via link behaviors) freacks Motion out. So I made another text layer which takes the text value from the original text layer but doesn't feed anything to the shape. So the setup is the following: sourceTextLayer defines the size of shapeLayer and feeds the text into displayTextLayer. After that I used the shapeLayer as a mask source for the displayTextLayer (which has no relation to shapeLayer).


That didn't work. Motion gets stuck. As well as me.


Maybe anyone got an idea?

Nov 9, 2022 11:08 AM in response to KirillSko

Things to avoid: Circular references especially where Align To is involved... Text (problems) can kill Motion faster than anything else.


I don't understand why you need to use shapeLayer rectangle as a mask...


However, when you do start running into circular reference problems... group, group, group, group, group...* (see way below).


Let me know more specifically what you're going for — in the meantime, here's some more information:


Groups (2D or 3D) have a unique behavior: they always represent the bounding box that just defines that area used by their contents. The only exception is when you set 2D Fixed Resolution and you can *define* the area they occupy. Things that travel outside this area in 2DFR disappear, so it's kind of like a mask itself. I'm **NOT** suggesting you use a 2DFR group for a mask... just saying that's a last course measure that's available to be taken...


You can apply Masks to Groups. The Mask "material" does not "count" with respect to the Group bounding box, i.e., it doesn't affect the size of the group (unless it is ultimately visible). If the Text object and its masks materials are the only things inside the group, then the Group bounding box stays "fixed" at the boundaries of the text.


*3D Text is slightly different. In regular text, characters are defined within their character space and there are typographical considerations at play (like a little space on each side of a characters "definition" so that characters don't run into each other when typed... computers don't calculate that space, it's defined in the font, a kind of "padding" if you will. With 3D Text, Motion actually creates a bounding box that "touches" the edges of the text regardless of "padding" (which is most helpful when modelling but can create minor issues when treating it as "regular" text.)


You can have Groups within Groups within Groups — ad infinitum if you need a way to isolate any item and use those its properties for calculations, transforming, blending, etc., as well as masking. For calculations, you could have several objects inside a single group, then simply Group an individual object you need to target for that kind of information.


Another option at your disposal is the Clone. Instead of duplicating a Text Object, clone it. You won't have to worry about things like Font, Font Size, tracking, kerning, etc., etc., etc.! or linking those properties. Cloning also gives you access to measurable properties that can be manipulated by Link.


Another tip: You can't think of "objects" as anything unique in Motion. All objects (this includes groups) have the same Properties. Any object can be a "null object" (visibility checkmark off) — an unseen "holder" of properties to be distributed among other objects. Don't be afraid to add as many extra (null) objects as you need. They're just performing math functions for you and don't add to the actual rendering of scenes. Don't stay too focused on just what you want people to see. [PS - a "null" is different than an object with 0% Opacity!]


In Motion, there's usually more than one way to "skin a cat".




This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

"Source value above minimum" in link behavior

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.