Merge branch 'alexdesktopworking' of https://github.com/sugarcubes/SugarCubes into...
authorAlexander Green <alexandergreen22@gmail.com>
Sun, 8 Sep 2013 09:03:56 +0000 (02:03 -0700)
committerAlexander Green <alexandergreen22@gmail.com>
Sun, 8 Sep 2013 09:03:56 +0000 (02:03 -0700)
kiselev added some debugging tools

ArjunBanker.pde [new file with mode: 0644]
BenMorrow.pde
SugarCubes.pde
_Overlay.pde
data/abstract.jpg [new file with mode: 0644]

diff --git a/ArjunBanker.pde b/ArjunBanker.pde
new file mode 100644 (file)
index 0000000..dcd5fae
--- /dev/null
@@ -0,0 +1,90 @@
+
+class TelevisionStatic extends SCPattern {
+  BasicParameter brightParameter = new BasicParameter("BRIGHT", 1.0);
+  BasicParameter saturationParameter = new BasicParameter("SAT", 1.0);
+  BasicParameter hueParameter = new BasicParameter("HUE", 1.0);
+  SinLFO direction = new SinLFO(0, 10, 3000);
+  
+  public TelevisionStatic(GLucose glucose) {
+    super(glucose);
+    addModulator(direction).trigger();
+    addParameter(brightParameter);
+    addParameter(saturationParameter);
+    addParameter(hueParameter);
+  }
+
+ void run(int deltaMs) {
+    boolean d = direction.getValuef() > 5.0;
+    for (Point p : model.points) {             
+      colors[p.index] = color((lx.getBaseHuef() + random(hueParameter.getValuef() * 360))%360, random(saturationParameter.getValuef() * 100), random(brightParameter.getValuef() * 100));
+    }
+  }
+}
+
+class AbstractPainting extends SCPattern {
+  
+  PImage img;
+  
+  SinLFO colorMod = new SinLFO(0, 360, 5000);
+  SinLFO brightMod = new SinLFO(0, model.zMax, 2000);
+    
+  public AbstractPainting(GLucose glucose) {
+    super(glucose);
+    addModulator(colorMod).trigger();
+    addModulator(brightMod).trigger();
+    
+    img = loadImage("abstract.jpg");
+    img.loadPixels();    
+  } 
+  void run(int deltaMs) {    
+    for (Point p : model.points) {
+      color c = img.get((int)((p.x / model.xMax) * img.width), img.height - (int)((p.y / model.yMax) * img.height));
+      colors[p.index] = color(hue(c) + colorMod.getValuef()%360, saturation(c), brightness(c) - ((p.fz - brightMod.getValuef())/p.fz));
+    }    
+  }       
+}
+
+class Spirality extends SCPattern {
+  final BasicParameter r = new BasicParameter("RADIUS", 0.5);
+  
+  float angle = 0;
+  float rad = 0;
+  int direction = 1;
+  
+  Spirality(GLucose glucose) {
+    super(glucose);   
+    addParameter(r);
+    for (Point p : model.points) {  
+      colors[p.index] = color(0, 0, 0);
+    }
+  }
+    
+  public void run(int deltaMs) {
+    angle += deltaMs * 0.007;
+    rad += deltaMs * .025 * direction;
+    float x = model.xMax / 2 + cos(angle) * rad;
+    float y = model.yMax / 2 + sin(angle) * rad;
+    for (Point p : model.points) {    
+      float b = dist(x,y,p.fx,p.fy);
+      if (b < 90) {
+        colors[p.index] = blendColor(
+          colors[p.index],
+          color(lx.getBaseHuef() + 25, 10, map(b, 0, 10, 100, 0)),
+          ADD);        
+        } else {
+      colors[p.index] = blendColor(
+        colors[p.index],
+        color(25, 10, map(b, 0, 10, 0, 15)),
+        SUBTRACT); 
+      }
+    }
+    if (rad > model.xMax / 2 || rad <= .001) {
+      direction *= -1;
+    }
+  }
+}
+
+
+
+
index 9314c3ce44318661de3af7095c8b0eaa48a259a3..87b22be2ad785a4db8369a91b375fa388fe976de 100755 (executable)
@@ -1,3 +1,85 @@
+class TowerParams extends SCPattern
+{
+       BasicParameter hueoff = new BasicParameter("Hueoff", 0.0);
+       BasicParameter hueSpan = new BasicParameter("HueRange", 0.0);
+       BasicParameter t1 = new BasicParameter("T1", 0.0);
+       BasicParameter t2 = new BasicParameter("T2", 0.0);
+       BasicParameter t3 = new BasicParameter("T3", 0.0);
+       BasicParameter t4 = new BasicParameter("T4", 0.0);
+       BasicParameter t5 = new BasicParameter("T5", 0.0);
+       BasicParameter t6 = new BasicParameter("T6", 0.0);
+       BasicParameter t7 = new BasicParameter("T7", 0.0);
+       BasicParameter t8 = new BasicParameter("T8", 0.0);
+       BasicParameter t9 = new BasicParameter("T9", 0.0);
+       BasicParameter t10 = new BasicParameter("T10", 0.0);
+       BasicParameter t11 = new BasicParameter("T11", 0.0);
+       BasicParameter t12 = new BasicParameter("T12", 0.0);
+       BasicParameter t13 = new BasicParameter("T13", 0.0);
+       BasicParameter t14 = new BasicParameter("T14", 0.0);
+       BasicParameter t15 = new BasicParameter("T15", 0.0);
+       BasicParameter t16 = new BasicParameter("T16", 0.0);
+
+       ArrayList<BasicParameter> towerParams;
+       int towerSize;
+       int colorSpan;
+       TowerParams(GLucose glucose) {
+               super(glucose);
+
+               towerParams = new ArrayList<BasicParameter>();
+               addParameter(hueoff);
+               addParameter(hueSpan);
+               towerParams.add(t1);
+               towerParams.add(t2);
+               towerParams.add(t3);
+               towerParams.add(t4);
+               towerParams.add(t5);
+               towerParams.add(t6);
+               towerParams.add(t7);
+               towerParams.add(t8);
+               towerParams.add(t9);
+               towerParams.add(t10);
+               towerParams.add(t11);
+               towerParams.add(t12);
+               towerParams.add(t13);
+               towerParams.add(t14);
+               towerParams.add(t15);
+               towerParams.add(t16);
+               for(BasicParameter p : towerParams)
+               {
+                       addParameter(p);
+               }
+               towerSize = model.towers.size();
+               colorSpan = 255 / towerSize;
+               println("towers "+towerSize);
+       }
+
+       void run(int deltaMs)
+       {
+               clearALL();
+               Tower t;
+               for(int i=0; i<towerSize ;i++)
+               {       
+                       t= model.towers.get(i);
+                       for(Point p : t.points)
+                       {
+                               if(p.y<towerParams.get(i).getValuef()*200)
+                               {
+                                       colors[p.index]=color(255 * hueoff.getValuef()+colorSpan * hueSpan.getValuef() * i, 255, 255);
+                               }
+                       }
+               }
+
+       }
+
+       public void clearALL()
+       {
+               for(Point p : model.points)
+               {
+                       colors[p.index] = 0;
+               }
+       }
+
+}
 class Sandbox extends SCPattern
 {
        int c=0;
index 472285283397867711152f1d6d1a4946dfea190e..7f8be7b14a9837d7f5fb5bb5453030b94f804110 100644 (file)
@@ -78,12 +78,19 @@ LXPattern[] patterns(GLucose glucose) {
     new TimSpheres(glucose),
 
     // Ben
+    //new Sandbox(glucose),
+    new TowerParams(glucose),
     new DriveableCrossSections(glucose),
     new GranimTestPattern2(glucose),
      
     // Sam
     new JazzRainbow(glucose),
     
+    // Arjun
+    new TelevisionStatic(glucose),
+    new AbstractPainting(glucose),
+    new Spirality(glucose),
+    
     // Basic test patterns for reference, not art    
     new TestCubePattern(glucose),
     new TestTowerPattern(glucose),
index f1bc1d4a8a9df06038cb7a924772c98d38fa7373..2623e8276fb668135acc5a4f039fc0a8cb92e35f 100644 (file)
@@ -771,6 +771,13 @@ class DebugUI {
   final int debugXSpacing = 28;
   final int debugYSpacing = 21;
   final int[][] debugState;
+  final int[] indexState;
+  
+  final int ERROR_STATE_USED = 0;
+  final int ERROR_STATE_DUPLICATED = 1;
+  
+  final int CUBE_STATE_UNUSED = 0;
+  final int CUBE_STATE_USED = 1;
   
   final int DEBUG_STATE_ANIM = 0;
   final int DEBUG_STATE_WHITE = 1;
@@ -779,6 +786,7 @@ class DebugUI {
   DebugUI(PandaMapping[] pandaMappings) {
     int totalChannels = pandaMappings.length * PandaMapping.CHANNELS_PER_BOARD;
     debugState = new int[totalChannels+1][ChannelMapping.CUBES_PER_CHANNEL+1];
+    indexState = new int[glucose.model.cubes.size()+1];
     
     channelList = new ChannelMapping[totalChannels];
     int channelIndex = 0;
@@ -792,6 +800,16 @@ class DebugUI {
         debugState[i][j] = DEBUG_STATE_ANIM;
       }
     }
+    
+    for (int rawIndex = 0; rawIndex < glucose.model.cubes.size()+1; rawIndex++) {
+      indexState[rawIndex] = CUBE_STATE_UNUSED;
+    }
+    for (ChannelMapping channel : channelList) {
+      for (int rawCubeIndex : channel.objectIndices) {
+        if (rawCubeIndex > 0)
+          indexState[rawCubeIndex]++;
+      }
+    }
   }
   
   void draw() {    
@@ -822,7 +840,7 @@ class DebugUI {
               stroke(#999999);          
               line(xPos - 12, yPos + 8, xPos, yPos + 8);
             }
-            drawNumBox(xPos, yPos, rawCubeIndex, debugState[channelNum][stateIndex+1]);
+            drawNumBox(xPos, yPos, rawCubeIndex, debugState[channelNum][stateIndex+1], indexState[rawCubeIndex]);
             ++stateIndex;
             xPos += debugXSpacing;            
           }
@@ -846,12 +864,41 @@ class DebugUI {
       ++channelNum;
     }
     drawNumBox(xBase, yPos, "A", debugState[channelNum][0]);
+    yPos += debugYSpacing * 2;
+   
+    noFill();
+    stroke(#CCCCCC);
+    rect(xBase, yPos, 100, 16);
+    fill(#CCCCCC);
+    text("Unused Cubes",  xBase + 5, yPos + 12);
+    yPos += debugYSpacing;
+    
+    int x_index = 0;
+    for (int rawIndex = 1; rawIndex < glucose.model.cubes.size()+1; rawIndex++) {
+      if (indexState[rawIndex] == 0) {
+        drawNumBox(xBase + (x_index * debugXSpacing), yPos, rawIndex, 0, 2);
+        x_index++;
+        if (x_index > 4) {
+          x_index = 0;
+          yPos += debugYSpacing + 2;
+        }
+      }
+    }
   }
+
   
   void drawNumBox(int xPos, int yPos, int label, int state) {
     drawNumBox(xPos, yPos, "" + label, state);
   }
   
+  void drawNumBox(int xPos, int yPos, int label, int state, int cube_state) {
+    if (cube_state > 1) {
+      fill(#FF0000);
+      rect(xPos-2, yPos-2, 20, 20);
+    }
+    drawNumBox(xPos, yPos, label, state);
+  }
+  
   void drawNumBox(int xPos, int yPos, String label, int state) {
     noFill();
     color textColor = #cccccc;
diff --git a/data/abstract.jpg b/data/abstract.jpg
new file mode 100644 (file)
index 0000000..dc90da2
Binary files /dev/null and b/data/abstract.jpg differ