Add many blend transition types, remove dualblender and gplay stuff
[SugarCubes.git] / MarkSlee.pde
index 68d8de143f334e81c41b3317ff9f9286f586ef4e..d22386a1d8f5d6ba1bcd2e7aaf5aac3987752c37 100644 (file)
@@ -128,6 +128,84 @@ class SwipeTransition extends SCTransition {
   }
 }
 
+abstract class BlendTransition extends SCTransition {
+  
+  final int blendType;
+  
+  BlendTransition(GLucose glucose, int blendType) {
+    super(glucose);
+    this.blendType = blendType;
+  }
+
+  void computeBlend(int[] c1, int[] c2, double progress) {
+    if (progress < 0.5) {
+      for (int i = 0; i < c1.length; ++i) {
+        colors[i] = lerpColor(
+          c1[i],
+          blendColor(c1[i], c2[i], blendType),
+          (float) (2.*progress),
+          RGB);
+      }
+    } else {
+      for (int i = 0; i < c1.length; ++i) {
+        colors[i] = lerpColor(
+          c2[i],
+          blendColor(c1[i], c2[i], blendType),
+          (float) (2.*(1. - progress)),
+          RGB);
+      }
+    }
+  }
+}
+
+class MultiplyTransition extends BlendTransition {
+  MultiplyTransition(GLucose glucose) {
+    super(glucose, MULTIPLY);
+  }
+}
+
+class ScreenTransition extends BlendTransition {
+  ScreenTransition(GLucose glucose) {
+    super(glucose, SCREEN);
+  }
+}
+
+class BurnTransition extends BlendTransition {
+  BurnTransition(GLucose glucose) {
+    super(glucose, BURN);
+  }
+}
+
+class DodgeTransition extends BlendTransition {
+  DodgeTransition(GLucose glucose) {
+    super(glucose, DODGE);
+  }
+}
+
+class OverlayTransition extends BlendTransition {
+  OverlayTransition(GLucose glucose) {
+    super(glucose, OVERLAY);
+  }
+}
+
+class AddTransition extends BlendTransition {
+  AddTransition(GLucose glucose) {
+    super(glucose, ADD);
+  }
+}
+
+class SubtractTransition extends BlendTransition {
+  SubtractTransition(GLucose glucose) {
+    super(glucose, SUBTRACT);
+  }
+}
+
+class SoftLightTransition extends BlendTransition {
+  SoftLightTransition(GLucose glucose) {
+    super(glucose, SOFT_LIGHT);
+  }
+}
+
 class BassPod extends SCPattern {
 
   private GraphicEQ eq = null;
@@ -705,3 +783,35 @@ class Traktor extends SCPattern {
     }
   }
 }
+
+class ColorFuckerEffect extends SCEffect {
+  
+  BasicParameter hueShift = new BasicParameter("HSHFT", 0);
+  BasicParameter sat = new BasicParameter("SAT", 1);  
+  BasicParameter bright = new BasicParameter("BRT", 1);
+  
+  ColorFuckerEffect(GLucose glucose) {
+    super(glucose);
+    addParameter(hueShift);
+    addParameter(bright);
+    addParameter(sat);    
+  }
+  
+  public void doApply(int[] colors) {
+    if (!enabled) {
+      return;
+    }
+    float bMod = bright.getValuef();
+    float sMod = sat.getValuef();
+    float hMod = hueShift.getValuef();
+    if (bMod < 1 || sMod < 1 || hMod > 0) {    
+      for (int i = 0; i < colors.length; ++i) {
+        colors[i] = color(
+          (hue(colors[i]) + hueShift.getValuef()*360.) % 360,
+          saturation(colors[i]) * sat.getValuef(),
+          brightness(colors[i]) * bright.getValuef()
+        );
+      }
+    }
+  }
+}