Context Index
Intro
The Context Index Utility acts as an input that only exists during the computation of the Layers. Layers that have an input connection from other Layers may choose to provide context to these input layers to produce different results. The Duplicator is one such Layer providing an index context to all of its inputs.
Check out the Context page for some background reading on this concept.
This utility allows us to use the context information to achieve more specific and intricate results.
To visualise the 'index context', follow these steps:
- Create a Text Shape.
- Using the
+
button next to the String attribute, add a String Generator. - Set Generator to Value.
- Set Precision and Padding to 0.
- Add the Text Shape to a Duplicator.
- On the Grid Distribution set the Count to X = 1, Y = 10.
- Create a Context Index Utility.
- Connect contextIndex.id→stringGenerator.number.
The Duplicator includes an Index Context attribute under its Advanced tab. It's possible to skip creating the Context Index Utility and connect directly from the Duplicator instead. e.g. Replace steps 7 and 8 above with:
- Connect duplicator.indexContext→stringGenerator.number.
Nothing too unexpected there. So let's take this a bit further.
Context Depth
When a layer provides context, it gets added to a chain of contexts. If we have a Duplicator within a Duplicator, then the chain will contain two index contexts. What the Context Index allows you to do is choose the 'depth' of those contexts provided to other layers.
Example (continued from the previous example):
- Add the Duplicator to a second Duplicator.
- Set Duplicator2's Grid Distribution to Count X = 5, Count Y = 1.
Result: The index value travels through the second Duplicator.
Duplicator1 automatically accumulates the index from Duplicator2, which is why we get numbers ranging from 0 to 49 even though we have selected a Depth value of 1. We can change this: 3. In the Attribute Editor, uncheck Use Index Context under Duplicator1's Advanced tab.
Result: The numbers now represent the index from Duplicator1.
- Set Depth on the Content Index to 2.
Result: The numbers now represent the index coming from Duplicator2.
Bonus
Combining Context Index Utilities with a Jsmath Utility can create some interesting results.
- Create another Context Index Utility.
- Ensure Depth is set to 1 (default).
- Create a Jsmath Utility.
- Connect contextIndex2.id→jsmath.array.0.
- Set the Expression to be:
0.5 + n0 * n0 * 0.01
. - Connect jsmath.id→duplicator1.shapeScale.x.
- Connect jsmath.id→duplicator1.shapeScale.y.