Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

New routines, Gamma.

  • Loading branch information...
commit 15268eceb1a2cd8083071bc0d3cde762bb0d7cd8 1 parent 0a80936
@potatono potatono authored
View
11 Greetz.pde
@@ -10,6 +10,14 @@ class Greetz extends Routine {
};
String message = "N Y C R";
+ public Greetz() {
+ }
+
+ public Greetz(String[] messages) {
+ this.messages = messages;
+ this.message = messages[0];
+ }
+
void setup(PApplet parent) {
super.setup(parent);
font = loadFont("Disorient-" + FONT_SIZE + ".vlw");
@@ -22,7 +30,7 @@ class Greetz extends Routine {
fill(255);
if (w == 0) {
- w = -int((message.length()-1) * (FONT_SIZE*1.35) + WIDTH);
+ w = -int((message.length()-1) * (FONT_SIZE*1.25) + WIDTH);
}
fill(255,128,64);
@@ -46,6 +54,7 @@ class Greetz extends Routine {
x = HEIGHT;
message = messages[int(random(messages.length))];
w = 0;
+ println("Signalling newMode");
newMode();
}
}
View
2  Lines.pde
@@ -7,7 +7,7 @@ class Lines extends Routine {
int x = int(frame % 5);
for (int i = -x; i<WIDTH; i+=5) {
- line(i, 0, i+8, 8);
+ line(i, 0, i+height, height);
}
if (frame > FRAMERATE*TYPICAL_MODE_TIME) {
View
29 Rings.pde
@@ -0,0 +1,29 @@
+class Rings extends Routine {
+ int y = 0;
+ float xofs = 0;
+
+ void setup(PApplet parent) {
+ super.setup(parent);
+ background(0);
+ }
+
+ void draw() {
+ //background(0);
+
+ for (int x=0; x<width; x++) {
+ stroke(abs(int(sin((sin(xofs)*width+x)*1.0/width*3.14)*255)));
+
+ point(x,y);
+ }
+
+ xofs += PI/(width*3);
+
+ if (frameCount % 4 == 0) {
+ y++;
+
+ if (y>height)
+ y=0;
+ }
+ }
+}
+
View
87 Sculpture.pde
@@ -35,7 +35,7 @@ public class Sculpture {
public static final int ADDRESSING_HORIZONTAL_NORMAL = 4;
public static final int ADDRESSING_HORIZONTAL_HALF = 5;
public static final int ADDRESSING_HORIZONTAL_FLIPFLOP = 6;
-
+
PApplet parent;
UDP udp;
String address;
@@ -45,6 +45,9 @@ public class Sculpture {
int addressingMode;
byte buffer[];
int pixelsPerChannel;
+ float gammaValue = 2.5;
+ boolean enableGammaCorrection = false;
+ boolean isRGB = false;
public Sculpture(PApplet parent, int w, int h, boolean isRGB) {
this.parent = parent;
@@ -53,12 +56,13 @@ public class Sculpture {
this.port = 58082;
this.w = w;
this.h = h;
+ this.isRGB = isRGB;
int bufferSize = (isRGB ? 3 : 1)*(w*h)+1;
buffer = new byte[bufferSize];
this.addressingMode = ADDRESSING_VERTICAL_NORMAL;
// TODO Detect this based on VERTICAL (h/2) vs. HORIZONTAL (w/2)
this.pixelsPerChannel = 8;
-
+
for (int i=0; i<bufferSize; i++) {
buffer[i] = 0;
}
@@ -71,15 +75,23 @@ public class Sculpture {
public void setPort(int port) {
this.port = port;
}
-
+
public void setAddressingMode(int mode) {
this.addressingMode = mode;
}
-
+
public void setPixelsPerChannel(int n) {
this.pixelsPerChannel = n;
}
-
+
+ public void setGammaValue(float gammaValue) {
+ this.gammaValue = gammaValue;
+ }
+
+ public void setEnableGammaCorrection(boolean enableGammaCorrection) {
+ this.enableGammaCorrection = enableGammaCorrection;
+ }
+
private int getAddress(int x, int y) {
if (addressingMode == ADDRESSING_VERTICAL_NORMAL) {
return (x * h + y);
@@ -113,52 +125,67 @@ public class Sculpture {
return (y * h + x);
}
}
-
+
return 0;
}
-
+
public void sendMode(String modeName) {
byte modeBuffer[] = new byte[modeName.length()+1];
-
+
modeBuffer[0] = 2;
- for(int i = 0; i < modeName.length(); i++) {
+ for (int i = 0; i < modeName.length(); i++) {
modeBuffer[i+1] = (byte)modeName.charAt(i);
}
-
- udp.send(modeBuffer,address,port);
+
+ udp.send(modeBuffer, address, port);
}
-
+
int maxSentByte = 0;
public void sendData() {
PImage image = get();
-
-// if (image.width != w || image.height != h) {
-// image.resize(w,h);
-// }
-
+
+ // if (image.width != w || image.height != h) {
+ // image.resize(w,h);
+ // }
+
image.loadPixels();
loadPixels();
-
+
int r;
int g;
int b;
buffer[0] = 1;
for (int y=0; y<h; y++) {
for (int x=0; x<w; x++) {
- r = int(brightness(image.pixels[y*w+x]));
- buffer[(getAddress(x,y)+1)] = byte(r);
-
- //r = int(red(image.pixels[y*w+x]));
- //g = int(green(image.pixels[y*w+x]));
- //b = int(blue(image.pixels[y*w+x]));
- //buffer[(getAddress(x,y)*3)+1] = byte(r);
- //buffer[(getAddress(x,y)*3)+2] = byte(g);
- //buffer[(getAddress(x,y)*3)+3] = byte(b);
+
+ if (isRGB) {
+ r = int(red(image.pixels[y*w+x]));
+ g = int(green(image.pixels[y*w+x]));
+ b = int(blue(image.pixels[y*w+x]));
+
+ if (enableGammaCorrection) {
+ r = (int)(Math.pow(r/256.0,this.gammaValue)*256);
+ g = (int)(Math.pow(g/256.0,this.gammaValue)*256);
+ b = (int)(Math.pow(b/256.0,this.gammaValue)*256);
+ }
+
+ buffer[(getAddress(x, y)*3)+1] = byte(r);
+ buffer[(getAddress(x, y)*3)+2] = byte(g);
+ buffer[(getAddress(x, y)*3)+3] = byte(b);
+ }
+ else {
+ r = int(brightness(image.pixels[y*w+x]));
+
+ if (enableGammaCorrection) {
+ r = (int)(Math.pow(r/256.0,this.gammaValue)*256);
+ }
+
+ buffer[(getAddress(x, y)+1)] = byte(r);
+ }
}
}
updatePixels();
- udp.send(buffer,address,port);
- }
+ udp.send(buffer, address, port);
+ }
}
-
View
90 Warp.pde
@@ -0,0 +1,90 @@
+class Warp extends Routine {
+ float r;
+ float rofs;
+ float warpSpeed;
+ Routine subroutine;
+ boolean warpHorizontal;
+ boolean warpVertical;
+ float warpFactor;
+
+ public Warp() {
+ this.subroutine = null;
+ warpHorizontal = false;
+ warpVertical = true;
+ warpSpeed = 1;
+ warpFactor = 1;
+ }
+
+ public Warp(Routine subroutine, boolean warpHorizontal, boolean warpVertical, float warpSpeed, float warpFactor) {
+ this.subroutine = subroutine;
+ this.warpHorizontal = warpHorizontal;
+ this.warpVertical = warpVertical;
+ this.warpSpeed = warpSpeed;
+ this.warpFactor = warpFactor;
+ }
+
+ void setup(PApplet parent) {
+ super.setup(parent);
+
+ if (this.subroutine != null) {
+ this.subroutine.setup(parent);
+ }
+ }
+
+ void hshift(int y, int xofs) {
+ if (xofs < 0)
+ xofs = width + xofs;
+
+ PImage tmp = get(width-xofs,y,xofs,1);
+ copy(0,y,width-xofs,1, xofs,y,width-xofs,1);
+ image(tmp,0,y);
+ }
+
+ void vshift(int x, int yofs) {
+ if (yofs < 0)
+ yofs = height + yofs;
+
+ PImage tmp = get(x,height-yofs,1,yofs);
+ copy(x,0,1,height-yofs, x,yofs,1,height-yofs);
+ image(tmp,x,0);
+ }
+
+ void drawBackground() {
+ if (subroutine != null) {
+ subroutine.draw();
+
+ if (subroutine.isDone) {
+ newMode();
+ }
+ }
+ else {
+ background(0);
+ fill(255);
+ ellipseMode(CORNER);
+ ellipse(0,0,width-1,height-1);
+ }
+ }
+
+ void draw() {
+ drawBackground();
+
+ if (warpVertical) {
+ for (int x=0; x<width; x++) {
+ r = x*1.0/height*PI + rofs;
+ vshift(x,int(sin(r)*(height*warpFactor)));
+ }
+
+ rofs += 0.0314 * warpSpeed;
+ }
+
+ if (warpHorizontal) {
+ for (int y=0; y<height; y++) {
+ r = y*1.0/width*PI + rofs;
+ hshift(y,int(sin(r)*(width*warpFactor)));
+ }
+
+ rofs += 0.0314 * warpSpeed;
+ }
+ }
+}
+
View
9 Waterfall.pde
@@ -11,14 +11,19 @@ class Waterfall {
public void reset() {
x = int(random(0, WIDTH));
y = -1;
- len = random(1, 5);
+ len = random(1, height/2);
v = random(0.1, 1);
}
public void draw() {
y = y + v;
- rect(x, y, 0.1, len);
+// rect(x, y, 0.1, len);
+ for (int j=0; j<len; j++) {
+ stroke(int(sin(j*1.0/len*3.14)*255));
+ point(x,y+j);
+ }
+
if (y > HEIGHT) this.reset();
}
View
12 acw.pde
@@ -17,21 +17,23 @@ String hostname = "127.0.0.1"; //"192.168.1.130";
int TYPICAL_MODE_TIME = 300;
Routine[] enabledRoutines = new Routine[] {
- // new Greetz(),
+ // new Greetz(new String[] { "COUNTRY", "CLUB", "D12ORIENT" }),
// new Bursts(),
// new FlashColors(), /* rainbow */
// new Flash(), /* seizure mode */
-// new Lines(), /* boring */
+ // new Lines(), /* boring */
// new OppositeLines(), /* boring */
// new Waves(), /* ? */
// new HorizonScan(),
// new RadialStars(),
// new NightSky(),
// new TargetScanner(),
-// new Waterfalls(),
+// new Warp(new Waterfalls(), true, false, 0.5, 0.25)
// new RGBRoutine(),
- new FFTDemo(),
- // new FollowMouse()
+ // new FFTDemo(),
+ // new FollowMouse(),
+ //new Warp(new Greetz(new String[] { "COUNTRY CLUB", "D12ORIENT" }), false, true, 1, 0.25)
+ new Warp(null, true, true, 0.5, 0.25)
};
int w = 0;
Please sign in to comment.
Something went wrong with that request. Please try again.