Merge branch 'master' of https://github.com/sugarcubes/SugarCubes into alexgreen
authorAlexander Green <alexandergreen22@gmail.com>
Sat, 9 Nov 2013 11:28:55 +0000 (03:28 -0800)
committerAlexander Green <alexandergreen22@gmail.com>
Sat, 9 Nov 2013 11:28:55 +0000 (03:28 -0800)
Conflicts:
AlexGreen.pde

1  2 
AlexGreen.pde
MarkSlee.pde

diff --combined AlexGreen.pde
index 910371a4c2dac3c2ea7eba695e8fe6286ea4b2f9,91677db78efd90e70327392cd6bafc857a3f4c45..d2220b790e2367b9578fecef68a0e223f8413464
@@@ -1,9 -1,9 +1,10 @@@
 -class SineSphere extends SCPattern {
 -  private SinLFO yrot = new SinLFO(0, TWO_PI, 2000);
 +class SineSphere extends DPat {
 +  private SawLFO yrot = new SawLFO(0, TWO_PI, 3000);
    public final Projection sinespin; 
 +  private BasicParameter rotation = new BasicParameter("rotation", 0);
   float modelrad = sqrt((model.xMax)*(model.xMax) + (model.yMax)*(model.yMax) + (model.zMax)*(model.zMax));
    Pick Sshape; 
+   public final PVector P = new PVector();
  
    class Sphery {
    float f1xcenter, f1ycenter, f1zcenter, f2xcenter , f2ycenter, f2zcenter; //second three are for an ellipse with two foci
@@@ -18,9 -18,6 +19,6 @@@
    public BasicParameter huespread;
    public BasicParameter bouncerate;
    public BasicParameter bounceamp;
-   public PVector circlecenter; 
-   
-   
   
    public Sphery(float f1xcenter, float f1ycenter, float f1zcenter, float vibration_min, float vibration_max, float vperiod) 
    {
@@@ -30,8 -27,8 +28,8 @@@
     this.vibration_min = vibration_min;
     this.vibration_max = vibration_max;
     this.vperiod = vperiod;
 -   addParameter(bounceamp = new BasicParameter("Amp", .5));
 -   addParameter(bouncerate = new BasicParameter("Rate", .5));  //ybounce.modulateDurationBy(bouncerate);
 +   //addParameter(bounceamp = new BasicParameter("Amp", .5));
 +   //addParameter(bouncerate = new BasicParameter("Rate", .5));  //ybounce.modulateDurationBy(bouncerate);
     addParameter(widthparameter = new BasicParameter("Width", .1));
     addParameter(huespread = new BasicParameter("Hue", .2));
     
      
     //addModulator(bounceamp); //ybounce.setMagnitude(bouncerate);
     addModulator( vibration = new SinLFO(vibration_min , vibration_max, 240000./lx.tempo.bpm())).trigger(); //vibration.modulateDurationBy(vx);
-    
+       
    }
   public Sphery(float f1xcenter, float f1ycenter, float f1zcenter, float f2xcenter, float f2ycenter, float f2zcenter, 
    float vibration_min, float vibration_max, float vperiod)  
 + 
   {
      this.f1xcenter = f1xcenter;
     this.f1ycenter = f1ycenter;
@@@ -73,21 -69,11 +71,21 @@@ float distfromcirclecenter(float px, fl
     return dist(px, py, pz, f1x, f1y, f1z);
      }
   //void updatespherey(deltaMs, )
 - color spheryvalue (float px, float py, float pz , float f1xc, float f1yc, float f1zc) 
 - {
 +
 + int quadrant(PVector q) {
 +   //float theta =  
 +  if (q.x > f1xcenter ) {return 140;}
 +    else  {return 250;}
 +
 +
 +
 + }
 + color spheryvalue (PVector p, float f1xcenter, float f1ycenter, float f1zcenter) 
 + {  circlecenter = new PVector(f1xcenter, f1ycenter, f1zcenter);
  //switch(sShpape.cur() ) {}  
 -   return lx.hsb(constrain(huespread.getValuef()*5*px, 0, 360) , dist(px, py, pz, f1xc, f1yc, f1zc) , 
 -    max(0, 100 - 100*widthparameter.getValuef()*abs(dist(px, py, pz, f1xcenter, ybounce.getValuef(), f1zcenter)
 +   return lx.hsb(constrain( huespread.getValuef()*5*quadrant(p), 0, 360) ,
 +    PVector.dist(p,circlecenter) , 
 +    max(0, 100 - 100*widthparameter.getValuef()*abs(PVector.dist(p, circlecenter)
        - vibration.getValuef() ) ) ); 
   }
   color ellipsevalue(float px, float py, float pz , float f1xc, float f1yc, float f1zc, float f2xc, float f2yc, float f2zc)
@@@ -110,13 -96,11 +108,13 @@@ void run(double deltaMs) 
  
  
  final Sphery[] spherys;
 + 
    SineSphere(GLucose glucose) 
    {
      super(glucose);
      sinespin = new Projection(model);
      addModulator(yrot).trigger();
 +    addParameter(rotation);
      //Sshape = addPick("Shape", , 1);
      spherys = new Sphery[] {
        new Sphery(model.xMax/4, model.yMax/2, model.zMax/2, modelrad/16, modelrad/8, 3000),
  //     }
  //   }
  
 -     void run( double deltaMs) {
 +    public void run( double deltaMs) {
       float t = lx.tempo.rampf();
       float bpm = lx.tempo.bpmf();
 -     //spherys[1].run(deltaMs);
 -     //spherys[2].run(deltaMs);
 -     //spherys[3].run(deltaMs);]
 +     spherys[0].run(deltaMs);
 +     spherys[1].run(deltaMs);
 +     spherys[2].run(deltaMs);
       sinespin.reset(model)
  
 -     // Translate so the center of the car is the origin, offset by yPos
 +     // Translate so the center of the car is the origin, offset 
        .translateCenter(model, 0, 0, 0)
 +     // .scale(1.3,1.3,1.3)
 +      // Rotate around the origin (now the center of the car) about an y-vector
 +      .rotate(yrot.getValuef(), 0, 1 , 0)
 +      .translate(model.cx, model.cy, model.cz);
 +      
  
 -      // Rotate around the origin (now the center of the car) about an X-vector
 -      .rotate(yrot.getValuef(), 0, 1, 0);
 -
 -
 +      //.translateCenter(model, model.cx, , model.cz);
 +   
  
 -     for (Point p: model.points){
 +     for (Coord p: sinespin)
 +   // for (Point p: model.points)
 +     {
 +      PVector P = new PVector(p.x, p.y, p.z);
      color c = 0;
 -    c = blendColor(c, spherys[1].spheryvalue(p.x, p.y, p.z, .75*model.xMax, model.yMax/2, model.zMax/2), ADD);
 -    c = blendColor(c, spherys[0].spheryvalue(p.x, p.y, p.z, model.xMax/4, model.yMax/4, model.zMax/2), ADD);
 -    c = blendColor(c, spherys[2].spheryvalue(p.x, p.y, p.z, model.xMax/2, model.yMax/2, model.zMax/2),ADD);
 +    c = blendColor(c, spherys[1].spheryvalue(P, .75*model.xMax, model.yMax/2, model.zMax/2), ADD);
 +    c = blendColor(c, spherys[0].spheryvalue(P, model.xMax/4, model.yMax/4, model.zMax/2), ADD);
 +    c = blendColor(c, spherys[2].spheryvalue(P, model.xMax/2, model.yMax/2, model.zMax/2),ADD);
       
        colors[p.index] = lx.hsb(lx.h(c), lx.s(c), lx.b(c));
  
@@@ -243,13 -221,13 +241,13 @@@ PVector centerofcube(int i) 
  Cube c = model.cubes.get(i);
  
  println(" cube #:  " + i + " c.x  "  +  c.x  + "  c.y   "  + c.y   + "  c.z  "  +   c.z  );
 -PVector cubeangle = new PVector(c.rx, c.ry, c.rz);
 -//println("raw x" + cubeangle.x + "raw y" + cubeangle.y + "raw z" + cubeangle.z);
 +// PVector cubeangle = new PVector(c.rx, c.ry, c.rz);
 +println("raw x angle:  " + c.rx + "raw y angle:  " + c.ry + "raw z angle:  " + c.rz);
  PVector cubecenter = new PVector(c.x + CW/2, c.y + CH/2, c.z + CW/2);
  println("cubecenter unrotated:  "  + cubecenter.x + "  "  +cubecenter.y + "  " +cubecenter.z );
 -PVector centerrot = new PVector(cos(c.rx)*CW/2 - sin(c.rx)*CW/2, 0, cos(c.rz)*CW/2 + sin(c.rz)*CW/2);
 +PVector centerrot = new PVector(cos(c.rx)*CW/2 - sin(c.rx)*CW/2, cubecenter.y, cos(c.rz)*CW/2 + sin(c.rz)*CW/2);
   // nCos*(y-o.y) - nSin*(z-o.z) + o.y
 -cubecenter = PVector.add(cubecenter, centerrot);
 +cubecenter = PVector.add(new PVector(c.x, c.y, c.z), centerrot);
  println( "  cubecenter.x  " + cubecenter.x  + " cubecenter.y  " +  cubecenter.y + " cubecenter.z  "   +  cubecenter.z  + "   ");
  
  
diff --combined MarkSlee.pde
index 3d6cda6b47293b392a1a329d9177b5958d4cd031,4a3720640f88985bb871d76cdede3329204d7e71..d3237e1e64fb2204e0ee6a41950ad80855e3d9cd
@@@ -57,10 -57,10 +57,10 @@@ class Cathedrals extends SCPattern 
        if (abs(p.x - cx) < arm) {
          d = min(abs(p.x - cx), abs(p.y - middle));
        }
-       colors[p.index] = color(
+       colors[p.index] = lx.hsb(
          (lx.getBaseHuef() + .2*abs(p.y - model.cy)) % 360,
          min(100, sf*dist(abs(p.x - cx), p.y, arm, middle)),
-         max(0, 120 - d*falloff));
+         constrain(120 - d*falloff, 0, 100));
      }
    } 
  }
@@@ -110,7 -110,7 +110,7 @@@ class MidiMusic extends SCPattern 
        }
        float posf = position.getValuef();
        for (Point p : model.points) {
-         colors[p.index] = blendColor(colors[p.index], color(
+         colors[p.index] = blendColor(colors[p.index], lx.hsb(
            (lx.getBaseHuef() + .2*abs(p.x - model.cx) + .2*abs(p.y - model.cy)) % 360,
            100,
            max(0, bright - posf*100 - falloff*abs(p.y - posf*model.yMax))
        for (Point p : s.points) {
          int wavi = (int) constrain(p.x / model.xMax * wval.length, 0, wval.length-1);
          float wavb = max(0, wave.getValuef()*100. - 8.*abs(p.y - wval[wavi]));
-         colors[p.index] = color(
+         colors[p.index] = lx.hsb(
            (lx.getBaseHuef() + .2*abs(p.x - model.cx) + .2*abs(p.y - model.cy)) % 360,
            100,
            constrain(wavb + max(0, maxBright - 40.*abs(sparklePos - abs(i - (Cube.POINTS_PER_STRIP-1)/2.))), 0, 100)
@@@ -516,7 -516,7 +516,7 @@@ class BouncyBalls extends SCPattern 
      float zPos;
      
      BouncyBall(int i) {
-       addModulator(xPos).setBasis(random(0, TWO_PI)).start();
+       addModulator(xPos.setBasis(random(0, TWO_PI)).start());
        addModulator(yPos = new Accelerator(0, 0, 0));
        zPos = lerp(model.zMin, model.zMax, (i+2.) / (NUM_BALLS + 4.));
      }
@@@ -644,7 -644,7 +644,7 @@@ class SpaceTime extends SCPattern 
  }
  
  class Swarm extends SCPattern {
+   
    SawLFO offset = new SawLFO(0, 1, 1000);
    SinLFO rate = new SinLFO(350, 1200, 63000);
    SinLFO falloff = new SinLFO(15, 50, 17000);
          colors[p.index] = lx.hsb(
          (lx.getBaseHuef() + 0.3 * abs(p.x - hOffX.getValuef())) % 360, 
          constrain(80 + 40 * fV, 0, 100), 
 -        constrain(100 - (30 - fV * falloff.getValuef()) * modDist(i + (s*63)%61, offset.getValuef() * strip.metrics.numPoints, strip.metrics.numPoints), 0, 100)
 +        constrain(100 - 
 +          (30 - fV * falloff.getValuef()) * modDist(i + (s*63)%61, offset.getValuef() * strip.metrics.numPoints, strip.metrics.numPoints), 0, 100)
            );
          ++i;
 -      }
 +      } 
        ++s;
      }
    }
@@@ -931,7 -930,7 +931,7 @@@ class BoomEffect extends SCEffect 
        boom.trigger();
      }
  
-     void doApply(int[] colors) {
+     void apply(int[] colors) {
        float brightv = 100 * bright.getValuef();
        float falloffv = falloffv();
        float satv = sat.getValuef() * 100;
      onEnable();
    }
  
-   public void doApply(int[] colors) {
+   public void apply(int[] colors) {
      for (Layer l : layers) {
        if (l.boom.isRunning()) {
-         l.doApply(colors);
+         l.apply(colors);
        }
      }
    }
@@@ -1405,14 -1404,14 +1405,14 @@@ class ColorFuckerEffect extends SCEffec
      addParameter(invert);
    }
    
-   public void doApply(int[] colors) {
+   public void apply(int[] colors) {
      if (!enabled) {
        return;
      }
      float bMod = level.getValuef();
      float sMod = 1 - desat.getValuef();
      float hMod = hueShift.getValuef();
-     float fSharp = 1/(1.0001-sharp.getValuef());
+     float fSharp = sharp.getValuef();
      float fSoft = soft.getValuef();
      boolean mon = mono.getValuef() > 0.5;
      boolean ivt = invert.getValuef() > 0.5;
            hsb[2] = 1 - hsb[2];
          }
          if (fSharp > 0) {
-           hsb[2] = hsb[2] < .5 ? pow(hsb[2],fSharp) : 1-pow(1-hsb[2],fSharp);
+           fSharp = 1/(1-fSharp);
+           if (hsb[2] < .5) {
+             hsb[2] = pow(hsb[2],fSharp);
+           } else {
+             hsb[2] = 1-pow(1-hsb[2],fSharp);
+           }
          }
          if (fSoft > 0) {
            if (hsb[2] > 0.5) {
@@@ -1457,7 -1461,7 +1462,7 @@@ class QuantizeEffect extends SCEffect 
      lastQuant = 0;
    } 
    
-   public void doApply(int[] colors) {
+   public void apply(int[] colors) {
      float fQuant = amount.getValuef();
      if (fQuant > 0) {
        float tRamp = (lx.tempo.rampf() % (1./pow(2,floor((1-fQuant) * 4))));
  
  class BlurEffect extends SCEffect {
    
-   final LXParameter amount = new BasicParameter("AMT", 0);
+   final BasicParameter amount = new BasicParameter("AMT", 0);
    final int[] frame;
    final LinearEnvelope env = new LinearEnvelope(0, 1, 100);
    
      env.setRangeFromHereTo(0, 1000).start();
    }
    
-   public void doApply(int[] colors) {
+   public void apply(int[] colors) {
      float amt = env.getValuef() * amount.getValuef();
      if (amt > 0) {    
        amt = (1 - amt);