Numbers and Variables

Numbers and Variables

A number variable, or Number, gives a numeric value a name so you can reuse it across attributes in a document.

The Variable Values panel

Define a number with a name, value, and editing options. Use its name in supported numeric fields to link object attributes to that value.

For example, use the same number for a stroke width and a blur radius. Editing that number updates both attributes. Numbers can also serve as symbol parameters.

Conditions supply on/off values for supported checkboxes and other two-state controls.

Selectors supply values for controls with several choices. Manage them in the Variable Values panel, but create them in the control where they will be used.

Variables

Numbers, conditions, and selectors are collectively called variables. Create and manage them in Variable Values (shown as Values in the panel title).

The panel lists variables defined in the current document. Use its buttons and menu commands to edit or remove them.

Each variable displays controls suited to its type, so you can edit its value directly in the panel.

The following options are available as panel icons:

  • Rename variable - Rename the selected variable.
  • Variable options - Edit the options of the selected variable.
  • Duplicate variables - Duplicate the selected variables.
  • Create number variable - Create a new number variable.
  • Create measurement variable - Create a number variable based on an object measurement.
  • Create condition - Create a new condition variable.
  • Remove variables - Remove the selected variables.

Variable panel menu

The Variable Values panel menu

The panel menu provides commands for organizing variables, similar to those in the Styles panel:

The following options are available from the menu:

  • Show Folders - Check to show the folders of the variable (and style) definition hierarchy.
  • Listing Mode - Select the sorting mode of variables in the list.
  • Document Styles - Show variables defined in the current document.
  • Current Canvas Styles - Show variables defined in the current canvas.
  • Selected Object Styles - Show variables defined in the selected objects.
  • Duplicate - Duplicate the selected variables.
  • Edit Variable - Edit the options of the selected variable.
  • Edit Variable Name - Edit the name of the selected variable.
  • Number from Object - Create a measurement number variable from the selected object.
  • Number from Function - Create a number variable that is a function of another number variable.
  • Detach Selected - Disconnect the selected variables from their place of use.
  • Replace Variables - Replace a variable with another one in all instances in the document.
  • Remove - Remove the selected variables.
  • Create Group - Create a folder in the variable (style) hierarchy.
  • Group Selected - Group the selected variables into a folder.
  • Copy - Copy the selected variables to the clipboard.
  • Cut - Copy the selected variables to the clipboard and remove their definitions.
  • Paste - Paste variable definitions from the clipboard.
  • Update Variables - Update the variables from a file.
  • Files - Import and export variables.

Number Variables

Number variable options

Use a number variable in a supported numeric field to link that attribute to a shared value. Edit the variable once to update every attribute that uses it.

Insert a number variable into text to display its value. The text updates when the number changes.

Click Create number variable in Variable Values to create a number. Set the following options:

  • Name - Set the name of the variable.
  • Editor - Choose a control suited to the value, such as a percentage, length, or whole-number count.
  • Number - Set the value of the number variable.
  • Minimum - Set the minimum value of the number variable.
  • Maximum - Set the maximum value of the number variable.
  • Units - Choose the units used when displaying the number in text.
  • Precision - Set the decimal precision used when displaying the value in text.
  • Width - Set the decimal display width for integers inserted into text.
  • Append Units - Include the unit name after the number in text.

Use number variables in numeric fields that support them.

Control-click a supported numeric field, such as stroke width, and choose a variable from the menu. The field stays linked to the variable and updates when its value changes.

Editing a number in Variable Values updates every attribute that uses it.

Number Function Variables

Number function options

Choose Number from Function in the Variable Values panel menu to derive a number from another variable. The source can be a regular number, measurement, or expression. The function’s result updates whenever the source changes.

Number function variables are defined using the following options:

  • Name - Name the function variable.
  • Define the function in the editor on the left.
  • Number - Select a previously defined number variable.
  • Minimum In - Set the minimum input. Lower values are raised to this limit.
  • Maximum In - Set the maximum input. Higher values are lowered to this limit.
  • Minimum Out - Set the minimum value of the resulting number.
  • Maximum Out - Set the maximum value of the resulting number.
  • Units - Choose the units used when displaying the number in text.
  • Precision - Set the decimal precision used when displaying the value in text.
  • Width - Set the decimal display width for integers inserted into text.
  • Append Units - Include the unit name after the number in text.

Expressions

Numeric fields that support variables also accept mathematical expressions. Shift+Control-click a field to open an expanded editor, then enter a single-line expression using variable names, numbers, and mathematical operators.

The attribute stays linked to the expression. It recalculates whenever a variable used by the expression changes.

The following functions can be used in expressions:

  • cos(x) - Cosine of x, where x is measured in degrees.
  • sin(x) - Sine of x, where x is measured in degrees.
  • tan(x) - Tangent of x, where x is measured in degrees.
  • acos(x) - Returns the angle in degrees for a cosine value x.
  • asin(x) - Returns the angle in degrees for a sine value x.
  • atan(x) - Returns the angle in degrees for a tangent value x.
  • atan2(y, x) - Returns the angle in degrees for the (x, y) point.
  • cosh(x) - Returns the hyperbolic cosine of x.
  • sinh(x) - Returns the hyperbolic sine of x.
  • acosh(x) - Returns the inverse hyperbolic cosine of x.
  • asinh(x) - Returns the inverse hyperbolic sine of x.
  • exp(x) - Returns e raised to x.
  • log(x) - Returns the natural logarithm of x.
  • log10(x) - Returns the base-10 logarithm of x.
  • exp2(x) - Returns 2 raised to x.
  • log2(x) - Returns the base-2 logarithm of x.
  • pow(x, y) - Returns a power of the base x raised to exponent y.
  • sqrt(x) - Returns the square root of x.
  • cbrt(x) - Returns the cube root of x.
  • hypot(x, y) - Returns the hypotenuse of x and y (the square root of the sum of squares of x and y).
  • abs(x) - Returns the absolute value of x.
  • average(x0, x1, …) - Returns the average of the numbers passed as parameters.
  • clamp(v, min, max) - Limits the value of v between the minimum and maximum.
  • clampmin(v, min) - Limits the value of v to a minimum.
  • clampmax(v, max) - Limits the value of v to a maximum.
  • copysign(x, y) - Returns the number x with the sign of y.
  • dim(x, y) - Returns the difference between x and y or 0 if the result would be negative.
  • fmod(x, y) - Returns the remainder of the division of x by y.
  • fraction(x) - Returns the fractional part of x.
  • lerp(a, b, t) - Returns a linear interpolation between a and b at the position t.
  • min(x0, x1, …) - Returns the minimum of the numbers passed as parameters.
  • max(x0, x1, …) - Returns the maximum of the numbers passed as parameters.
  • round(x) - Rounds the value of x up or down.
  • floor(x) - Rounds the value of x down.
  • ceil(x) - Rounds the value of x up.
  • gamma(x) - Returns the gamma function of x.
  • remainder(x, y) - Returns the remainder for x divided by y.
  • erf(x) - Computes the error function of x.

Measurements

Measurement variable options

A measurement variable takes its value from a property of an existing object. Its value is calculated from the object rather than entered manually.

Click Create measurement variable, or choose Number from Object from the panel menu, to open the Object Measurement dialog:

  • Name - Set the name of the measurement variable.
  • Object - Choose the symbol to measure, or Default to measure the selected object.
  • Number - Choose the object property to measure.
  • Units - Choose the units used when displaying the number in text.
  • Precision - Set the decimal precision used when displaying the value in text.
  • Width - Set the decimal display width for integers inserted into text.
  • Append Units - Include the unit name after the number in text.

Use measurements to show an object’s area or path length as text in your chosen units. Changes to the shape update the measurement and any text displaying it.

Place the text cursor, then choose a number from Text - Insert Variable. Its value appears as text, formatted according to the variable’s options.

Selector Variables

A selector links a multiple-choice attribute to a shared setting. Changing the selector updates every attribute that uses it.

Create a selector in the control where it will be used, because its choices depend on the attribute type. Supported dropdowns include Create Style for this purpose.

The selector then appears in dropdowns for the same attribute type. Choose it to link an attribute, and edit its value in Variable Values using the available choices.

For example, choose Create Style from a blending-mode menu to create a selector. Apply it to several objects, then change the selector to update all their blending modes.

Text-on-path Alignment is another example. Use one selector for several text objects to control their vertical alignment relative to their paths.

Condition Variables

A menu of condition variables

Conditions link supported on/off attributes to shared values.

Create a condition in Variable Values, then double-click it to control the selected objects’ visibility.

To link a checkbox to a condition, Control-click it. Choose On or Off for a fixed value, or choose a condition or its negated value. A negated condition turns the attribute on when the condition is off, and vice versa.

Supported menu controls offer the same choices: a fixed on/off value, a condition, or a negated condition.

To control object or layer visibility with a condition:

  • Create or choose a condition to control visibility.
  • Click Create condition in Variable Values to create a condition.
  • Select the objects whose visibility will be controlled by a condition.
  • Select the condition in the Variable Values panel.
  • Double-click the condition name, to set the condition as the visibility condition of the selected objects.
  • These objects will be visible if the condition is enabled, and invisible otherwise.
  • Toggle the condition’s checkbox to control the objects’ visibility.
  • To remove the visibility condition from the selected objects, click the Remove variables button of the panel.

To use a condition for style activation:

  • Create or choose a condition to control style activation.
  • Open the activation options for the resource:
    • For style groups, the conditions will be shown in the Activation Mode submenu of the Styles panel menu. Select the conditions that must be enabled to activate the group.
    • For canvases, click Enable Mode in Canvas Options.
    • For linked documents, click Enable Mode in Linked Documents.
    • Select the conditions that should control the resource.
  • Toggle the condition in Conditions to activate or deactivate the resources that use it.