Cavalry
  • Welcome
  • Getting Started
    • Requirements
    • Installation
    • Sign In
      • Proxy Server
    • Quick Start
    • Example Files
    • Key Concepts
      • Nodes
      • Connections
      • Context
  • User Interface
    • Menus
      • File menu
      • Edit menu
      • View menu
      • Composition menu
      • Create menu
      • Animation menu
      • Shape menu
      • Tool menu
        • Select tool
        • Edit Shape tool
        • Pen tool
        • Pencil tool
        • Line tool
        • Text tool
        • Rectangle tool
        • Ellipse tool
        • Polygon tool
        • Star tool
        • Arc tool
        • Super Ellipse tool
        • Cog tool
        • Arrow tool
        • Capsule tool
      • Window menu
        • Align Window
        • Animation Utilities
        • Assets Window
          • Google Sheets Asset
          • Image Sequences
          • Project Settings
        • Attribute Editor
          • Control Rows
            • Controls Rows - Types
            • Control Rows - Interaction
        • Color window
          • Palettes
        • Control Center
        • Quick Add window
        • Flow Graph
        • Glyph Browser
        • Playback Controls
        • Preferences
        • Render Manager
          • Lottie Export
          • Dynamic Rendering
          • Render Tokens
        • Scene Window
          • Scene Tree
            • Composition Settings
          • Time Editor
          • Graph Editor
          • Keyframe Layers
        • Shelf
        • Tags
        • Toolbar
        • Viewport
          • Rulers
      • Help menu
    • Widgets
      • Gradient
      • Graph Attribute
    • General
      • Aliasing
      • Blend Modes
      • Distribution Types
        • Array Distribution
        • Circle Distribution
        • Fibonacci Distribution
        • Grid Distribution
        • Linear Distribution
        • Mask Distribution
        • Math Distribution
        • Path Distribution
        • Point Distribution
        • Random Distribution
        • Rose Distribution
        • Shape Edges Distribution
        • Shape Points Distribution
        • Shuffle Distribution
        • Sub-Mesh Distribution
        • Voxelize Distribution
      • Color Management
      • Motion Blur
      • Vector artwork support
  • Nodes
    • Shapes
      • Common Attributes (Shapes)
      • Background Shape
      • Basic Line
        • Bézier
        • Line
        • Spiral
      • Basic Shape
        • Arc
        • Arrow
        • Capsule
        • Cogwheel
        • Ellipse
        • Polygon
        • Rectangle
        • Ring
        • Star
        • Super Ellipse
      • Cel Animation Shape
      • Composition
      • Connect Shape
      • Convex Hull
      • Custom Shape
      • Duplicator
      • Editable Shape
      • Footage Shape
      • Group
      • Image to Shapes
      • Layout Shape
        • Grid Layout
        • Horizontal Layout
        • Vertical Layout
      • Outline
      • Points to Curve
      • Quad Tree Shape
      • Rectangle Pattern
      • SVG
      • Spacer
      • Sub-Mesh Bounding Box
      • Text Shape
      • Trails
    • Behaviours
      • Common Attributes (Behaviours)
      • 3D Matrix
      • Add Divisions
      • Align
      • Alpha Material Override
      • Apply Distribution
      • Apply Layout
      • Behaviour Mixer
      • Bevel
      • Blend Shape
      • Blend Sub-Mesh Positions
      • Boolean
      • Clean Up
      • Color Blend
      • Color Material Override
      • Curve to Lines
      • Distance
      • Fill Rule
      • Flare
      • Flatten Shape Layers
      • Frame
      • Get Vector
      • HSV Material Overide
      • Is Within
      • Look At
      • Manipulator
      • Material Sampler
      • Modulate
      • Morph
      • Noise
      • Number Range
      • Number Range to Color
      • Oscillator
      • Path Offset
      • Pathfinder
      • Pinch
      • Position Blend
      • Push Along Vector
      • Random
      • Resample Path
      • Round
      • Rubber Hose Limb
      • Simple Value Solver
      • Simple Value2 Solver
      • Skew
      • Sound
      • Split Path
      • Spring
      • Squetch
      • Stagger
      • Sub-Mesh
      • Subdivide
      • Swap Color Override
      • Value
      • Value 2
      • Value Blend
      • Value2 Blend
      • Visibility Sequence
      • Voxelize
    • Utilities
      • Animation Control
      • Apply Font Size
      • Array Manipulator
      • Asset Array
      • Bounding Box
      • Bounding Box Constraint
      • Color Array
      • Color Info
      • Composition Constraint
      • Component Constraint
      • Context Index
      • Falloff
      • Get Name
      • HSV Color
      • If Else
      • Index to Color
      • JS Math
      • Length Context
      • Local Time
      • Math
      • Math2
      • Math 3
      • Measure
      • Mesh Array
      • Null
      • Path Length
      • Regex
      • Rig Control
      • Sequence
      • Shader Array
      • Spreadsheet
      • Spreadsheet Lookup
      • String
      • String Array
      • String Generator
        • Formatted String Generator
        • Hash Generator
        • Hexadecimal Generator
        • Random Date Generator
        • Random Number Generator
        • Timecode Generator
        • Value Generator
      • String Length
      • String Manipulator
        • Change String Case Manipulator
        • Join String Manipulator
        • Replace String Manipulator
        • Regex String Manipulator
        • Resize String Manipulator
        • Shuffle String Manipulator
        • Sub-String Manipulator
        • Transition String Maniplulator
      • Transform Constraint
      • Typeface
      • Typeface Array
      • Value Array
      • Value 2 Array
      • Value 2 Array
      • Velocity Context
      • Velocity Magnitude Context
    • Effects
      • Blur
      • Color Shader
      • Drop Shadow
      • Fill
      • Gradient Shader
      • Image Shader
      • Invert
      • Levels
      • Linear Wipe
      • Mask Blur
      • Noise Shader
      • Radial Wipe
      • SkSL Shader
      • Shape to Shader
      • Tri Tone
      • Venetian Blinds
  • Tips
    • Shortcuts
  • Applications
    • Cavalry Player
    • Cavalry CLI
  • Technical Information
    • Licencing
    • Logs
    • Mathematical Expressions
    • Release Notes
      • 1.1.1 Release Notes
      • 1.1 Release Notes
      • 1.0.3 Release Notes
      • 1.0.2 Release Notes
      • 1.0.1 Release Notes
    • User Preferences
Powered by GitBook
On this page

Was this helpful?

  1. Getting Started
  2. Key Concepts

Context

The secret sauce

PreviousConnectionsNextMenus

Last updated 5 years ago

Was this helpful?

Cavalry's architecture does some amazing and unique things. On the surface this means you can do more with less elements but what's actually going on under the hood?

The underlying concept to understand is that of an Index. An index is simply a number passed to another Element. A fundamental part of a Duplicator's role is to assign indices to the Shapes it generates. This index can be used by the Duplicator and other Elements to dictate position, rotation, color, number of sides...anything really.

Let's say you've used a Duplicator to create a column of 10 rectangles.

In this case the Duplicator creates 10 indices and uses them simply to provide each duplicated Shape with a position based on the Distribution settings (in this case a Grid with a Height of 350 and a Size mode of Fit). Index:0 (the first shape) gets assigned a Position Y of 0 and Index:9 (the tenth/last shape) gets assigned a Position Y of 350 with the other Shapes distributed evenly between.

Ok, so what happens if we add this Duplicator to a second Duplicator? Here the second Duplicator has been set to a Grid of Count X = 5 and Count Y = 1.

As you can see the indices flow through to the second Duplicator's shapes. As you keep duplicating Duplicator's this index count will keep flowing through the graph.

So how about a practical example.

  1. Set the Generator to Value.

  2. On the Grid Distribution set the Count to X = 1, Y = 10. Result: A column of zeros.

The above is made possible by the fact that the Duplicator provides a Index to each number and the Random node utilises that context.

  • Duplicator asks Text Generator 10 times for its Number.

  • In turn, Text Generator asks Random 10 times for the value of its Number.

  • During those 10 times, Random receives Index values of: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.

  • Based on each index, Random alters its Seed value to produce different results.

You can apply this idea to any attribute in Cavalry. Let's do the same thing to affect the number of sides of a Polygon.

  1. Set Minimum to 3 and Maximum to 5.

  2. Connect random.id > polygon.sides.

Switching to manual

Now there are occasions when you might want manual control of how these indices are assigned. There are two levels to this. The first is to prevent the Duplicator from using the 'incoming index'.

Taking our example of a grid of rectangles (the duplicated Duplicator):

Now the indices from Duplicator1 are being cycled through to the second Duplicator.

Create a .

Add the Text Generator to a .

So, on the surface, there's nothing very interesting going on there but that's just because we've not asked the Duplicator to do anything with the indices. So let's ask it to create some random values to pass to the Number attribute.

Create a Behaviour.

random.id > textGenerator.number. Result: Each number is a random number between 0 and 10 (defaults).

Create a Shape.

Add it to a .

Add a Behaviour.

This concept can be used on Noise Deformers, Colors, Stroke Widths, Path Lengths, Blur Filters, Asset Arrays, Dynamic Rendering...anything. The possibilities are endless!

In the , right-click on Duplicator1's header bar and uncheck Advanced -> Use Incoming Index.

To take this idea even further you will need the help of the Atom.

😉
😎
Text Generator
Duplicator
Random
Connect
Polygon
Duplicator
Random
Attribute Editor
Context Index
The Duplicator passes random numbers to each duplicate.
Each shape is given a random number of sides of between 3 and 5.