updated the mini-documentation on pinwheels
[SugarCubes.git] / TestPatterns.pde
index 733494541ec28d1c5e6fce48ea7612007c2b1530..38ea2296200d31e7f13e370a7d1f3acc35a7df7d 100644 (file)
@@ -74,6 +74,33 @@ class TestZPattern extends SCPattern {
   }
 }
 
+/**
+ * This shows how to iterate over towers, enumerated in the model.
+ */
+class TestTowerPattern extends SCPattern {
+  private final SawLFO towerIndex = new SawLFO(0, model.towers.size(), 1000*model.towers.size());
+  
+  public TestTowerPattern(GLucose glucose) {
+    super(glucose);
+    addModulator(towerIndex).trigger();
+  }
+
+  public void run(int deltaMs) {
+    int ti = 0;
+    for (Tower t : model.towers) {
+      for (Point p : t.points) {
+        colors[p.index] = color(
+          lx.getBaseHuef(),
+          100,
+          max(0, 100 - 80*LXUtils.wrapdistf(ti, towerIndex.getValuef(), model.towers.size()))
+        );
+      }
+      ++ti;
+    }
+  }
+  
+}
+
 /**
  * This is a demonstration of how to use the projection library. A projection
  * creates a mutation of the coordinates of all the points in the model, creating