Permalink
Browse files

Merge branch 'dn-digital-love' of github.com:hackrockcity/domeTransmi…

…tter into dn-digital-love
  • Loading branch information...
2 parents 77cacdc + de8a584 commit 7cc49de6b7949c3da07eefba95c7ab6ebf5d5608 @jaredklett jaredklett committed Jan 26, 2013
Showing with 182 additions and 77 deletions.
  1. +3 −3 Animator.pde
  2. +45 −0 Bounce.pde
  3. +18 −7 ColorPicker.pde
  4. +42 −20 Fire.pde
  5. +38 −0 Hearts.pde
  6. +2 −2 Mirror.pde
  7. +14 −4 Swirl.pde
  8. +0 −36 Toss.pde
  9. +4 −1 Warp.pde
  10. +16 −4 domeTransmitter.pde
View
6 Animator.pde
@@ -50,9 +50,9 @@ class Animator extends Routine {
image(anim.update(),xNominal - width, yNominal - height);
image(anim.update(),xNominal, yNominal - height);
- if (frame > FRAMERATE*TYPICAL_MODE_TIME) {
- newMode();
- }
+ if ((frameCount - modeFrameStart)*4 > FRAMERATE*TYPICAL_MODE_TIME) {
+ newMode();
+ }
}
}
View
45 Bounce.pde
@@ -0,0 +1,45 @@
+class Bounce extends Routine {
+ int n = 100;
+ int[] x;
+ float[] y;
+ float[] s;
+
+ void setup(PApplet parent) {
+ super.setup(parent);
+ x = new int[n];
+ y = new float[n];
+ s = new float[n];
+
+ for (int i=0; i<n; i++) {
+ x[i] = int(random(0,width));
+ y[i] = random(0,height);
+ s[i] = random(0.5,2.5);
+ }
+ }
+
+ void draw() {
+ background(0);
+
+ for (int i=0; i<n; i++) {
+ color c = colorPicker.primaryColor;
+
+ y[i] += s[i] + (s[i]*controller.pitch/-135) + (s[i]*y[i]/height*2);
+ if (y[i]<0 || y[i]>height) {
+ s[i] = -s[i];
+ if (y[i]<0)
+ x[i] = (x[i]+width/2) % width;
+ }
+
+ for (int j=0; j<5; j++) {
+ stroke(c);
+ point(x[i],int(y[i] + (s[i]<0 ? j : -j)));
+ c = colorPicker.dim(c);
+ }
+ }
+
+ if (frameCount - modeFrameStart > FRAMERATE*TYPICAL_MODE_TIME) {
+ newMode();
+ }
+
+ }
+}
View
25 ColorPicker.pde
@@ -2,22 +2,32 @@ class ColorPicker {
color[] palette = new color[] {
color(255,255,255),
color(255,64,64),
- color(128,128,255),
- color(255,128,0),
+ color(64,255,255),
+ color(64,64,255),
color(64,255,64),
- color(0,255,128),
- color(128,0,255)
+ color(255,255,64),
+ color(255,64,255)
};
+ float dimRatio = 0.85;
int primary=0;
int secondary=1;
color primaryColor = palette[primary];
- color secondaryColor = palette[secondary];
+ color secondaryColor = color(255*dimRatio,64*dimRatio,64*dimRatio);
boolean wasButtonUp = false;
boolean wasButtonDown = false;
boolean wasButtonLeft = false;
boolean wasButtonRight = false;
+ color dim(color c) {
+ return color(red(c)*dimRatio,green(c)*dimRatio,blue(c)*dimRatio);
+ }
+
+ void forceGray() {
+ primaryColor = color(128);
+ secondaryColor = color(0);
+ }
+
void update() {
if (controller.buttonUp) wasButtonUp = true;
else if (wasButtonUp) {
@@ -39,14 +49,15 @@ class ColorPicker {
wasButtonLeft = false;
secondary -= 1;
if (secondary<0) secondary=palette.length-1;
- secondaryColor = palette[secondary];
+ secondaryColor = dim(palette[secondary]);
+
}
else if (controller.buttonRight) wasButtonRight = true;
else if (wasButtonRight) {
wasButtonRight = false;
secondary += 1;
if (secondary>=palette.length) secondary=0;
- secondaryColor = palette[secondary];
+ secondaryColor = dim(palette[secondary]);
}
}
}
View
62 Fire.pde
@@ -8,7 +8,15 @@ class Fire extends Routine {
int[] calc1, calc2, calc3, calc4, calc5;
PGraphics pg;
+ Routine subroutine = null;
+ public Fire() {
+ }
+
+ public Fire(Routine subroutine) {
+ this.subroutine = subroutine;
+ }
+
void setup(PApplet parent) {
super.setup(parent);
// size(640, 360, P2D);
@@ -49,34 +57,47 @@ class Fire extends Routine {
}
colorMode(RGB);
+
+ if (this.subroutine != null)
+ this.subroutine.setup(parent);
}
void draw() {
- angle = angle + 0.05;
-
-// // Rotating wireframe cube
-// pg.beginDraw();
-// pg.translate(displayWidth >> 1, displayHeight >> 1);
-// pg.rotateX(sin(angle/2));
-// pg.rotateY(cos(angle/2));
-// pg.background(0);
-// pg.stroke(128);
-// pg.scale(25);
-// pg.noFill();
-// pg.box(4);
-// pg.endDraw();
-
- // Randomize the bottom row of the fire buffer
- for (int x = 0; x < displayWidth; x++)
- {
- fire[x][displayHeight-1] = int(random(0, 190)) ;
+ if (this.subroutine != null) {
+ colorPicker.forceGray();
+ this.subroutine.draw();
+ loadPixels();
+ for (int i=0; i<pixels.length; i++)
+ pg.pixels[i] = brightness(pixels[i]) >= 128 ? color(128) : color(0);
+
+
+ if (this.subroutine.isDone) { newMode(); }
+ }
+ else {
+ angle = angle + 0.05;
+
+ // Rotating wireframe cube
+ pg.beginDraw();
+ pg.translate(displayWidth >> 1, displayHeight >> 1);
+ pg.rotateX(sin(angle/2));
+ pg.rotateY(cos(angle/2));
+ pg.background(0);
+ pg.stroke(128);
+ pg.scale(25);
+ pg.noFill();
+ pg.box(4);
+ pg.endDraw();
+
+ if (frameCount - modeFrameStart > FRAMERATE*TYPICAL_MODE_TIME) {
+ newMode();
+ }
}
loadPixels();
int counter = 0;
// Do the fire calculations for every pixel, from top to bottom
- for (int y = 0; y < displayHeight; y++) {
+ for (int y = displayHeight-1; y >= 0; y--) {
for (int x = 0; x < displayWidth; x++) {
// Add pixel values around current pixel
@@ -91,12 +112,13 @@ class Fire extends Routine {
// Extract the red value using right shift and bit mask
// equivalent of red(pg.pixels[x+y*w])
- if ((pg.pixels[counter++] >> 16 & 0xFF) == 128) {
+ if ((pg.pixels[counter++] >> 16 & 0xFF) >= 128) {
// Only map 3D cube 'lit' pixels onto fire array needed for next frame
fire[x][y] = 128;
}
}
}
+
updatePixels();
}
}
View
38 Hearts.pde
@@ -0,0 +1,38 @@
+class Hearts extends Routine {
+ float ofs = 0;
+ int[] heart = new int[] { 85,100,110,115,120,115,100,115,120,115,110,100,85 };
+
+ void setup(PApplet setup) {
+ ofs = width/4;
+ }
+
+ void draw() {
+ background(0);
+ stroke(255,255,255,192);
+ drawHeart((int)ofs);
+ stroke(255,64,64,192);
+ drawHeart((int)ofs*-1);
+
+ stroke(255,255,255,192);
+ drawHeart(((int)ofs+width/2));
+ stroke(255,64,64,192);
+ drawHeart(((int)ofs*-1+width/2));
+
+ ofs+=0.5;
+
+ if (frameCount - modeFrameStart > FRAMERATE*TYPICAL_MODE_TIME) {
+ newMode();
+ }
+ }
+
+ void drawHeart(int ofs) {
+ int x = ofs;
+ for (int i=0; i<heart.length; i++) {
+ x++;
+ while (x > width) x = x-width;
+ while (x < 0) x = x+width;
+ line(x,0,x,heart[i]*(0.25+abs(sin(ofs/20.0))));
+ }
+ }
+}
+
View
4 Mirror.pde
@@ -21,9 +21,9 @@ class Mirror extends Routine {
void draw() {
subroutine.draw();
-// mirror(offset + int((controller.roll/-90.0) * (width/2)));
+ mirror(offset);
- mirror(offset);
+ if (subroutine.isDone) { newMode(); }
}
void mirror(int ofs) {
View
18 Swirl.pde
@@ -2,6 +2,7 @@ class Swirl extends Routine {
float x=0;
float y=0;
float yo=0;
+ int weight = 5;
public Swirl() {
yo=random(0.3,0.7);
@@ -11,19 +12,28 @@ class Swirl extends Routine {
public Swirl(float speed) {
yo = speed;
}
+
+ public Swirl(float speed, int weight) {
+ this.yo = speed;
+ this.weight = weight;
+ }
void draw() {
background(0);
- strokeWeight(5);
+ strokeWeight(this.weight);
- for (x=-width; x<width+15; x+=5) {
+ for (x=-width; x<width*2; x+=this.weight) {
stroke((x % 2 == 0) ? colorPicker.primaryColor : colorPicker.secondaryColor);
line(x-y,0,x+width-y,height);
}
y+=yo + (yo*controller.pitch/-45);
- if (y>10) y-=10;
- else if (y<0) y+=10;
+ if (y>weight*2) y-=weight*2;
+ else if (y<0) y+=weight*2;
+
+ if (frameCount - modeFrameStart > FRAMERATE*TYPICAL_MODE_TIME) {
+ newMode();
+ }
}
}
View
36 Toss.pde
@@ -1,36 +0,0 @@
-class Toss extends Routine {
- float g;
- float ya;
- float ys;
- float y;
-
- public Toss() {
- ys=0;
- ya=0;
- y=0;
- g=10;
- }
-
- void draw() {
- ys += ya;
- ya += g;
- if (ya > g) ya = g;
- if (ys > g) ys = g;
- if (ya < -50) ya = -50;
- if (ys < -50) ys = -50;
- y += ys;
- while (y>height) y-=height;
- while (y<0) y+=height;
-
- println("ya="+ya+" ys="+ys+" y="+y);
- background(0);
- stroke(255);
- line(0,y,width,y);
-
- if (controller.dacc.y < 0) {
- println(controller.dacc.y);
- ya += controller.dacc.y;
- }
- }
-
-}
View
5 Warp.pde
@@ -66,7 +66,10 @@ class Warp extends Routine {
stroke(i%2==0 ? colorPicker.primaryColor : colorPicker.secondaryColor);
ellipse(displayWidth/2,displayHeight/2,i*(displayWidth/10),i*(displayHeight/10));
}
- }
+
+ if (frameCount - modeFrameStart > FRAMERATE*TYPICAL_MODE_TIME) {
+ newMode();
+ } }
}
void draw() {
View
20 domeTransmitter.pde
@@ -14,7 +14,7 @@ int displayHeight = 160;
boolean VERTICAL = false;
int FRAMERATE = 25;
-int TYPICAL_MODE_TIME = 300;
+int TYPICAL_MODE_TIME = 10;
float bright = 1; // Global brightness modifier
@@ -23,9 +23,20 @@ Routine pong = new Pong();
Routine backupRoutine = null;
Routine[] enabledRoutines = new Routine[] {
-// new Warp()
- new Mirror(new Swirl())
- //new Toss()
+ new Animator("anim-nyancat",1,.5,0,0,0),
+
+ new Hearts(),
+ new Bounce(),
+new Mirror(new Swirl()),
+new Swirl(0.5,15),
+new Warp(null, true, false, 0.5, 0.5),
+new Warp(new WarpSpeedMrSulu(), false, true, 0.5, 0.5),
+new Bursts()
+ //new Mirror(new Swirl())
+ //new Swirl(0.5,15)
+
+// new Warp(new Swirl(), true, true, 0.5, 0.5)
+ //new Mirror(new Swirl())
// new Crawl(),
// new Animator("anim-nyancat",1,.5,0,0,0),
// new Mirror(new Warp(new Swirl(0), false, true, 0.5, 0.9), width/2)
@@ -126,6 +137,7 @@ int seizure_count = 0; // Only let seizure mode work for a short time.
void draw() {
// ColorPicker allows controlling color with wiimote D-pad
colorPicker.update();
+ strokeWeight(1);
if (!controller.buttonB) {
switching_mode = false;

0 comments on commit 7cc49de

Please sign in to comment.