Skip to main content

Tutorial 3: Creating a Simple Motif

Let's create a complete motif with multiple elements.

Step 1: Plan the Pattern

We'll create:

  1. A center ring with 4 picots
  2. Four petal rings, each joining to one picot of the center
  3. Chains connecting the petals

Step 2: Write the Pattern

Create simple_motif.tatml:

pattern "Simple Four-Petal Motif" {
    thread: size20, variegated
    shuttles: 1
    
    // Center ring with 4 connection points
    center: R(4, p:north, 4, p:east, 4, p:south, 4, p:west, 4)
    
    // Four petals
    petal1: R(3, p, 3, join(center.north), 3, p, 3)
    petal2: R(3, p, 3, join(center.east), 3, p, 3)
    petal3: R(3, p, 3, join(center.south), 3, p, 3)
    petal4: R(3, p, 3, join(center.west), 3, p, 3)
    
    // Connecting chains
    chain1: C(5, join(petal1.picot2), 5, join(petal2.picot1), 5)
    chain2: C(5, join(petal2.picot2), 5, join(petal3.picot1), 5)
    chain3: C(5, join(petal3.picot2), 5, join(petal4.picot1), 5)
    chain4: C(5, join(petal4.picot2), 5, join(petal1.picot1), 5)
}

Step 3: Key Features Demonstrated

This pattern shows:

  • Named picots: p:north, p:east for easy reference
  • Precise joins: join(center.north) - no ambiguity
  • Complex connections: chains joining multiple elements
  • Comments: explaining the pattern structure

Step 4: Validate and Test

python3 tatml_validator.py simple_motif.tatml

The validator will check:

  • All referenced elements exist
  • All picot references are valid
  • Thread continuity makes sense
  • No impossible joins