Skip to content
This repository has been archived by the owner on Feb 21, 2020. It is now read-only.

Commit

Permalink
Adding code for the basic NorthTube color wash display
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Slee committed Nov 13, 2012
1 parent 47e6298 commit fa028bf
Show file tree
Hide file tree
Showing 5 changed files with 252 additions and 0 deletions.
42 changes: 42 additions & 0 deletions NorthTube/BlueWash.pde
@@ -0,0 +1,42 @@
/**
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/

class BlueWash extends LXPattern {

SinLFO pos = new SinLFO(0, lx.width-1, 39000);
SinLFO topbot = new SinLFO(0, 1, 14000);
SinLFO offset = new SinLFO(0, TWO_PI, 33000);
SinLFO satWid = new SinLFO(8, 13, 49000);

BlueWash(HeronLX lx) {
super(lx);
addModulator(pos).trigger();
addModulator(topbot).trigger();
addModulator(offset).trigger();
addModulator(satWid).trigger();
}

public void run(int deltaMs) {
for (int i = 0; i < lx.total; ++i) {
colors[i] = color(
(lx.getBaseHuef() + lerp(0, 20, abs(lx.column(i) - pos.getValuef()) / lx.width)) % 360,
constrain(100 - abs(sin((lx.column(i) - pos.getValuef())/satWid.getValuef())) * 70, 0, 100),
constrain(100 - abs(lx.row(i) - topbot.getValuef()) * 30 - sin(offset.getValuef() * lx.row(i) + (lx.column(i) - pos.getValuef())/20.) * 30, 0, 100)
);
}
}
}

36 changes: 36 additions & 0 deletions NorthTube/EvenOdd.pde
@@ -0,0 +1,36 @@
/**
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/

class EvenOdd extends LXPattern {
SinLFO eo = new SinLFO(0, 1, 19000);

EvenOdd(HeronLX lx) {
super(lx);
addModulator(eo).trigger();
eo.modulateDurationBy(addModulator(new SinLFO(5000, 13000, 21000)).trigger());
}

public void run(int deltaMs) {
for (int i = 0; i < lx.total; ++i) {
colors[i] = color(
lx.getBaseHuef(),
100,
constrain(100 - abs((lx.column(i) + lx.row(i)) % 2 - eo.getValuef()) * 80, 0, 100)
);
}
}
}

66 changes: 66 additions & 0 deletions NorthTube/NorthTube.pde
@@ -0,0 +1,66 @@
/**
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/

import com.heronarts.lx.*;
import com.heronarts.lx.kinet.*;
import com.heronarts.lx.modulator.*;
import com.heronarts.lx.pattern.*;
import com.heronarts.lx.transition.*;
import ddf.minim.*;

final color fbBlue = #3b5998;

void setup() {
size(1600, 180);
final HeronLX lx = new HeronLX(this, 95, 2);
final KinetNode[] nodes = new KinetNode[lx.total];

final KinetPort[] ports = {
new KinetPort("10.3.225.102", 1), // inner top
new KinetPort("10.3.217.57", 1), // outer top
new KinetPort("10.3.225.105", 1), // inner bottom
new KinetPort("10.3.217.65", 1), // outer bottom
};

for (int i = 0; i < lx.total; ++i) {
int row = lx.row(i);
int col = lx.column(i);
int kidx;
int pidx = row*2;
if (col < 45) {
kidx = 44 - col;
} else {
kidx = 94 - col;
++pidx;
}
nodes[i] = new KinetNode(ports[pidx], kidx);
}
lx.setKinetNodes(nodes);
lx.oscillateBaseHue((hue(fbBlue) + 300) % 360, (hue(fbBlue) + 60) % 360, 53000);
lx.enableAutoTransition(180000);

lx.setPatterns(new LXPattern[] {
new Shadows(lx).setTransition(new WipeTransition(lx, WipeTransition.Direction.LEFT).setDuration(10000)),
new BlueWash(lx).setTransition(new WipeTransition(lx, WipeTransition.Direction.LEFT).setDuration(10000)),
new EvenOdd(lx).setTransition(new WipeTransition(lx, WipeTransition.Direction.LEFT).setDuration(10000)),
new Scanners(lx).setTransition(new WipeTransition(lx, WipeTransition.Direction.LEFT).setDuration(10000)),
});

}

void draw() {
// triggers runloop
}
42 changes: 42 additions & 0 deletions NorthTube/Scanners.pde
@@ -0,0 +1,42 @@
/**
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/

class Scanners extends LXPattern {

SinLFO[] pos;
SinLFO[] falloff;

Scanners(HeronLX lx) {
super(lx);
pos = new SinLFO[lx.height];
falloff = new SinLFO[lx.height];
for (int i = 0; i < lx.height; ++i) {
addModulator(pos[i] = new SinLFO(0, lx.width-1, 4000+5000*i)).trigger();
pos[i].modulateDurationBy(addModulator(new SinLFO(13000, 29000, 18000 + i*3000)).trigger());
addModulator(falloff[i] = new SinLFO(0.6, 2, 19000+5000*i)).trigger();
}
}

public void run(int deltaMs) {
for (int i = 0; i < lx.total; ++i) {
colors[i] = color(
(lx.getBaseHuef() + lx.column(i) / 4.) % 360,
constrain(saturation(fbBlue) - abs(lx.column(i) - lx.width/2.), 0, 100),
constrain(100 - abs(lx.column(i) - pos[lx.row(i)].getValuef())*falloff[lx.row(i)].getValuef(), 0, 100)
);
}
}
}
66 changes: 66 additions & 0 deletions NorthTube/Shadows.pde
@@ -0,0 +1,66 @@
/**
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/

class Shadows extends LXPattern {

class Shadow {
SinLFO xPos;

Shadow() {
addModulator(xPos = new SinLFO(random(-2, 5), random(lx.width-5, lx.width+1), random(31000, 37000))).trigger();
xPos.setValue(random(5, lx.width-5));
}

float distance(int i) {
return abs(lx.column(i) - xPos.getValuef());
}
}

Shadow[] topShadows;
Shadow[] bottomShadows;

SinLFO topWashout, bottomWashout;

public Shadows(HeronLX lx) {
super(lx);
int NUM_SHADOWS = 4;
topShadows = new Shadow[NUM_SHADOWS];
bottomShadows = new Shadow[NUM_SHADOWS];
for (int i = 0; i < NUM_SHADOWS; ++i) {
topShadows[i] = new Shadow();
bottomShadows[i] = new Shadow();
}
addModulator(topWashout = new SinLFO(0, lx.width-1, random(9000, 15000))).trigger();
addModulator(bottomWashout = new SinLFO(0, lx.width-1, random(9000, 15000))).trigger();
}

public void run(int deltaMs) {
for (int i = 0; i < lx.total; ++i) {
float d = 100;
Shadow[] shadows = (lx.row(i) == 0) ? topShadows : bottomShadows;
for (Shadow s : shadows) {
d = min(d, s.distance(i));
}
SinLFO washout = (lx.row(i) == 0) ? topWashout : bottomWashout;
colors[i] = color(
(lx.getBaseHuef() + 10*sin(d/8.)) % 360,
constrain(abs(lx.column(i) - washout.getValuef()) * 4, 0, 100),
constrain(d*5, 0, 100)
);
}
}
}

0 comments on commit fa028bf

Please sign in to comment.