What are functions?
Certain properties of elements within the document can be defined as a function or formula. This function can refer to other elements properties and variable values.
To turn a static frame property into a calculated value based on a function, you simply click the function button next to the property input field in the interface.
A function field will appear below the property input field. The property input field is now no longer editable becuase the value is calculated based on the function defined in the function input field.
If a function is not valid and cannot be calculated properly, the last calculated value is kept.
What is supported within a function?
Arithmic operators
+ | adding |
- | substracting |
* | multiplying |
/ | deviding |
() | parentheses |
Referencing
In the functions, you can use absolute numbers, or you can reference other elements.
E.g. Start my frame 10mm left of the left side of the page / output
E.g. Position the top right of my logo 200px from the top/left corner of my banner
If the output then resized, the relative position of the element will move with the resize.
Functions can reference properties of frames, the page and also reference variable values. The way to do this is:
- For frames:
By typing the frame tag followed by a dot and the name of the property you want to reference. If frame tag contains a space or special character, the frame tag can still be used in the function but must be put between brackets. For example: [My frame tag]
- Page:
By typing “Page” followed by a dot, and the name of the property you want to reference. - Paragraph within a text frame:
A text paragraph can be tagged, and can also be referenced in a Dynamic Layout function. This is possible by first typing the name (tag) of the frame, followed by a dot, followed by the name of the paragraph (tag)
Bram Verniest (Unlicensed) new screenshot needed here
- Variable:
By typing the name of the variable, nothing more.
Properties (to reference of)
The following properties can be referenced on frame and page level:
Top | The Y value of the top of the referenced frame (or 0 for page) |
Bottom | The Y value of the bottom of the referenced frame or page |
Left | The X value of the left of the referenced frame (or 0 for page) |
Right | The X value of the right of the referenced frame or page |
CenterX | The Y value of the center of the referenced frame or page |
CenterY | The X value of the center of the referenced frame or page |
Width | The width of the referenced frame or page |
Height | The height of the referenced frame or page |
Functions within the calculation:
MinMax(min, max, input) | Clamps a given value between a minimum and maximum value |
ClampMin(min, input) | If the input value is less than the minimum, return the minimum value otherwise return the input value |
ClampMax(max, input) | If the input value is greater than the maximum, return the maximum value otherwise return the input value |
Use of units within a function
Units (millimeters, inches, points, pixels) can be used within a function.
If no unit is specified the Dynamic layout engine will assume the value is in points. Multiple units can be used within a single function.
E.g.:
frameA.width=50mm+10in+5pt