Merge branch 'master' of https://github.com/sugarcubes/SugarCubes
authorAlexander Green <alexandergreen22@gmail.com>
Thu, 8 Aug 2013 09:39:02 +0000 (02:39 -0700)
committerAlexander Green <alexandergreen22@gmail.com>
Thu, 8 Aug 2013 09:39:02 +0000 (02:39 -0700)
SugarCubes.pde
TobySegaran.pde [new file with mode: 0644]
fabric/HOWTOFABRIC.txt [deleted file]
fabric/fabfile.py [deleted file]
fabric/fabfile.pyc [deleted file]
fabric/startboth.pyc [deleted file]

index 801e2930f0f66bd01619db6414726f677bf28726..060a035aebdeb18da210932c8ec836537cca6fff 100644 (file)
@@ -34,6 +34,8 @@ LXPattern[] patterns(GLucose glucose) {
     new Psychedelia(glucose),
     new CubeEQ(glucose),
     new PianoKeyPattern(glucose),
+    new WarmPlasma(glucose),
+    new FireTest(glucose),
     
     // Basic test patterns for reference, not art    
 //    new TestCubePattern(glucose),
diff --git a/TobySegaran.pde b/TobySegaran.pde
new file mode 100644 (file)
index 0000000..650bbb0
--- /dev/null
@@ -0,0 +1,82 @@
+class WarmPlasma extends SCPattern {
+  private int pos = 0;
+  private float satu = 100;
+  private float speed = 1;
+  BasicParameter saturationParameter = new BasicParameter("SATU", 1.0);
+  BasicParameter speedParameter = new BasicParameter("SPEED", 0.1);
+  
+  public WarmPlasma(GLucose glucose) {
+    super(glucose);
+    addParameter(saturationParameter);
+    addParameter(speedParameter);
+  }
+  public void onParameterChanged(LXParameter parameter) {
+    if (parameter == saturationParameter) {
+      satu = 100*parameter.getValuef();
+    } else if (parameter == speedParameter) {
+      speed = 10*parameter.getValuef();
+    }
+  }
+
+  public void run(int deltaMs) {
+    for (Point p : model.points) {
+      float hv = sin(dist(p.fx + pos, p.fy, 128.0, 128.0) / 8.0)
+         + sin(dist(p.fx, p.fy, 64.0, 64.0) / 8.0)
+         + sin(dist(p.fx, p.fy + pos / 7, 192.0, 64.0) / 7.0)
+         + sin(dist(p.fx, p.fz + pos, 192.0, 100.0) / 8.0);
+      float bv = 100;
+      colors[p.index] = color((hv+2)*25, satu, bv);
+    }
+    pos+=speed;
+    if (pos >= MAX_INT-1) pos=0;
+  }
+}
+
+// This is very much a work in progress. Trying to get a flame effect.
+class FireTest extends SCPattern {
+  private float[][] intensity;
+  private float hotspot;
+  private float decay = 0.3;
+  private int xm;
+  private int ym;
+  BasicParameter decayParameter = new BasicParameter("DECAY", 0.3);
+  
+  public FireTest(GLucose glucose) {
+    super(glucose);
+    xm = int(model.xMax);
+    ym = int(model.yMax);
+    
+    intensity = new float[xm][ym];
+    addParameter(decayParameter);
+  }
+  public void onParameterChanged(LXParameter parameter) {
+    if (parameter == decayParameter) {
+      decay = parameter.getValuef();
+    }
+  } 
+  private color flameColor(float level) {
+    if (level<=0) return color(0,0,0);
+    float br=min(100,sqrt(level)*15);
+    return color(level/1.7,100,br);
+  }
+  public void run(int deltaMs) {
+    for (int x=10;x<xm-10;x++) {
+        if (x%50>45 || x%50<5) {
+          intensity[x][ym-1] = random(30,100);
+        } else {
+          intensity[x][ym-1] = random(0,50);
+        }
+    }
+    for (int x=1;x<xm-1;x++) {
+      for (int y=0;y<ym-1;y++) {        
+        intensity[x][y] = (intensity[x-1][y+1]+intensity[x][y+1]+intensity[x+1][y+1])/3-decay;
+      }
+    }
+    
+    for (Point p : model.points) {
+      int x = (int(p.fx)+int(p.fz))%xm;
+      int y = min(ym-int(p.fy),ym-1);
+      colors[p.index] = flameColor(intensity[x][y]);
+    }
+  }
+}
diff --git a/fabric/HOWTOFABRIC.txt b/fabric/HOWTOFABRIC.txt
deleted file mode 100644 (file)
index 9d79c36..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-Using fabric:
-
-Install:
-(http://docs.fabfile.org/en/1.7/installation.html)
-
-pip install fabric
-
-Tutorial:
-
-http://docs.fabfile.org/en/1.4.0/index.html#tutorial
-
-Usage:
-
-write a python file called fabfile.py (or add to the current one)
-
-annotate tasks with @task
-
-e.g:
-
-from fabric.api import run,env,task,sudo,cd
-
-@task
-def sayHelloAll():
-       print "Hello local"
-       run("echo Hello Remote")
-
-then from the command line:
-
-#shows all commands
-
-fab list
-
-# run a command
-
-fab sayHello
-
-# run command on specific host
-
-fab sayHello:host=192.168.1.29
-
-# run a command on a specific host with a specific user
-
-fab -u someUser startBoard:host=192.168.1.29
-
-Run multiple:
-
-fab task1 task2
-
-Run arbitrary remote command:
-
- fab [options] -- [shell command]
-
-
-
-
diff --git a/fabric/fabfile.py b/fabric/fabfile.py
deleted file mode 100644 (file)
index a6b1933..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-from fabric.api import run,env,task,sudo,cd
-
-env.user = 'sugarcubes'
-env.password = 'sugarcubes'
-env.hosts = ['192.168.1.28']
-
-@task
-def startBoard():
-       with cd('Desktop/SC_PB'):
-               sudo('./xc_PB 640 160 160 1000')
-
-@task
-def loadModule():
-       with cd('enable_arm_pmu-master'):
-               sudo('./load-module')
-
-@task
-def stopBoard():
-       sudo("ps -axcopid,command | grep \"xc_PB\" | awk '{ system(\"kill -9 \"$1) }'")
-
-@task
-def restartBoard():
-       stopBoard()
-       startBoard()
-
-#loadModule startBoard
\ No newline at end of file
diff --git a/fabric/fabfile.pyc b/fabric/fabfile.pyc
deleted file mode 100644 (file)
index 3686d49..0000000
Binary files a/fabric/fabfile.pyc and /dev/null differ
diff --git a/fabric/startboth.pyc b/fabric/startboth.pyc
deleted file mode 100644 (file)
index 1db9f97..0000000
Binary files a/fabric/startboth.pyc and /dev/null differ