Skip to content

Commit

Permalink
Clarify posterizeTime description; provide better examples
Browse files Browse the repository at this point in the history
  • Loading branch information
zlovatt committed Jun 21, 2021
1 parent fd24021 commit 7d3dc2c
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions docs/global.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,30 +137,53 @@ Number

.. _Global.posterizeTime:

posterizeTime(``framesPerSecond``)
**********************************
posterizeTime(``updatesPerSecond``)
***********************************

**Description**

This expression allows you to set the frame rate for a property to be lower than the frame rate of the composition.

For example, the following expression updates the property value with a random value once per second::

posterizeTime(1);
random()
The value passed in is _the number of times per second_ the expression should evaluate.

**Parameters**

=================== ======
``framesPerSecond`` Number
=================== ======
==================== ======
``updatesPerSecond`` Number
==================== ======

The framesPerSecond value becomes the frame rate from which the rest of the expression operates.
The ``updatesPerSecond`` value becomes the rate at which the rest of the expression operates.

**Type**

Number

**Examples**

To change a property to a random value 1 time per second::

posterizeTime(1);

random()

To change a 2d property (such as Position or Scale) to a random value 3 times per second::

posterizeTime(3);

var newValue = random(0, 100);
[newValue, newValue];

To change a property to a random value within a specified range, every 12 frames::

var holdFrames = 12;
var minValue = 50;
var maxValue = 100;

posterizeTime(1 / framesToTime(holdFrames);

var newValue = random(minValue, maxValue);
newValue;

----

.. _Global.value:
Expand Down

0 comments on commit 7d3dc2c

Please sign in to comment.