Variable

Variables are values that can be read or written in UML and are defined as follows:

let name = value

The above defines a variable name, whose value is value. value can be a value of type Float or Rect, or an expression that results in a value of type Float or Rect.

Variables can be defined repeatedly, but only the value of the last definition will be used. After defining a variable, you can use it when creating new elements or defining other variables.

Built-in variables

UML has the following built-in variables:

  • t: current time in seconds
  • top: ratio of actual height to actual width
  • o: sliding distance
  • joined: whether the activity has been joined, 1 if joined, 0 otherwise.
  • $h: The maximum height that the user can scroll, limit the user's scrolling range by setting the value of this variable

UML does not have event functionality. You can use t, o and the time of button press to add dynamic effects to the page, such as animation, page change, etc.

Global variable

Global variables are variables that can be read or written anywhere in the UML file. Global variables are defined as follows:

global name = @type

where type can only be btn. After that, you can still write into global variables by using the let keyword, only the last defined value will be used.

The activity interface is redrawn at every frame, which means that UML recalculates the values of all variables at every frame.

However, some properties of the button need to be kept constant between frames, so global variables are needed.