---
description: Output sequences of numbers.
---

# Modulate

[Common Attributes](common-attributes-behaviours) +

**Mode**:&#x20;

* **Remainder** - create a sequence based on a **Divisor** value.
* **Pass /Fail** - create a sequence based on whether the remainder is 0 (pass) or not (fail).
* **Custom Pattern** - create your own pattern.

**Divisor** - setting a value of **n** will create a sequence of numbers from **0 > n-1**. e.g. a value of **3** will create a sequence of **0,1,2,0,1,2,0**... (see below).

**Index Offset** - offset the order of the pattern. e.g. if your pattern is **0, 1, 2, 0, 1, 2**... an **Index Offset** of **1** will result in **1, 2, 0, 1, 2, 0**...

**Offset** - offset the start value. e.g. if your pattern is **0, 1, 2, 0, 1, 2**... an **Offset** of **2** will result in **2, 3, 4, 2, 3, 4**...

**Pass Value** - when the remainder **is** 0, output this value.

**Fail Value** - when the remainder **is not** 0, output this value.

**Custom Pattern** - enter a pattern of values separated by commas.

{% hint style="success" %}
Example usage **Remainder**:

1. Create 3 [Basic Shapes](../shapes/basic-shape) (circle, rectangle, polygon).
2. Select all 3 Shapes.
3. Hold `alt` and click the [Duplicator](../shapes/duplicator) [Shelf](../../user-interface/menus/window-menu/shelf) icon.
4. Set **Count** to **x = 5**, **y = 5** on the Duplicator.
5. Create a **Modulate**.
6. Set **Divisor** to **3**.
7. Connect _**modulate.id**_ > _**duplicator.shapeId**_.

With a **Divisor** of 3 **Modulate** is outputting values of _0, 1, 2, 0, 1, 2, 0_... so your **Duplicator** outputs _circle, rectangle, polygon, circle, rectangle, polygon, circle_... (depending on the order they were added).
{% endhint %}

{% hint style="success" %}
Example usage for **Pass/ Fail**:

1. Create a [Basic Shape](../shapes/basic-shape).
2. Select the Shape.
3. Hold `alt` and click the [Duplicator](../shapes/duplicator) [Shelf](../../user-interface/menus/window-menu/shelf) icon.
4. Set the **Distribution** to **Linear** on the Duplicator.
5. Set **Count** to **9** and **Size** to **900.**
6. Create a [Color Array](../utilities/color-array).
7. Add a second index and set a different color.
8. Connect _**colorArray.id > basicShape.FillColor**_.
9. Create a **Modulate** Behaviour.
10. Set **Mode** to **Pass/ Fail**.
11. Set **Divisor** to **3**.
12. Connect _**modulate.id > colorArray.index**_.

The resulting sequence is **0,1,1,0,1,1,0**... (see below for the math). If your **Pass Value = 0** and **Fail Value = 1** then that translates to **pass, fail, fail, pass, fail, fail, pass**... If the colors on your Color Array are red and green the resulting sequence of colors will then be **red, green, green, red, green, green, red, green**...
{% endhint %}

{% hint style="info" %}
The **Remainder** and **Pass/ Fail** modes use **Modular Math**.

Here we're dividing a _number_ using a **Divisor** of **3**. Observe what happens to the **remainder** value as the _number_ increments by one.

* 0/3 = 0 remainder **0**
* 1/3 = 0 remainder **1**
* 2/3 = 0 remainder **2**
* 3/3 = 1 remainder **0**
* 4/3 = 1 remainder **1**
* 5/3 = 1 remainder **2**
* 6/3 = 2 remainder **0**
* **...**

As you can see, the remainders start at **0** and increase by **1** each time, until the number reaches one less than the **Divisor**. After that, the sequence repeats. So, if you wanted to create the sequence **0,1,2,3,0,1,2,3,**... you'd need a **Divisor** of **4**.
{% endhint %}
