//spherys[1].run(deltaMs);
//spherys[2].run(deltaMs);
//spherys[3].run(deltaMs);]
- sinespin.reset(model)
+ sinespin.reset()
// Translate so the center of the car is the origin, offset by yPos
- .translateCenter(model, 0, 0, 0)
+ .center()
// Rotate around the origin (now the center of the car) about an X-vector
.rotate(yrot.getValuef(), 0, 1, 0);
- for (Point p: model.points){
+ for (LXPoint p : model.points){
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);
// if (i%3 == 0){
-// for (Point p : c.points ){
+// for (LXPoint p : c.points ){
// // colors[p.index]=color(0,0,0);
// //float dif = (p.y - c.y);
// //colors[p.index] = color( bg.getValuef() , 80 , dif < curl.getValuef() ? 80 : 0, ADD);
// else if (i%3 == 1) {
-// for (Point p: c.points){
+// for (LXPoint p: c.points){
// colors[p.index]=color(0,0,0);
// float dif = (p.y - c.y);
// // colors[p.index] =
// }
// else if (i%3 == 2){
// centerlist[i].sub(cubeorigin(i);
- for (Point p: c.points) {
+ for (LXPoint p: c.points) {
PVector pv = new PVector(p.x, p.y, p.z);
colors[p.index] =color( constrain(4* pv.dist(centerlist.get(i)), 0, 360) , 50, 100 );
// colors[p.index] =color(constrain(centerlist[i].x, 0, 360), constrain(centerlist[i].y, 0, 100), );
}
void run(double deltaMs){
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
color c = 0;
c = blendColor(c, lx.hsb(360*HueT.getValuef(), 100*SatT.getValuef(), 100*BriT.getValuef()), ADD);
colors[p.index]= c;
void run(double deltaMs) {
boolean d = direction.getValuef() > 5.0;
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
colors[p.index] = lx.hsb((lx.getBaseHuef() + random(hueParameter.getValuef() * 360))%360, random(saturationParameter.getValuef() * 100), random(brightParameter.getValuef() * 100));
}
}
}
void run(double deltaMs) {
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
color c = img.get((int)((p.x / model.xMax) * img.width), img.height - (int)((p.y / model.yMax) * img.height));
colors[p.index] = lx.hsb(hue(c) + colorMod.getValuef()%360, saturation(c), brightness(c) - ((p.z - brightMod.getValuef())/p.z));
}
Spirality(GLucose glucose) {
super(glucose);
addParameter(r);
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
colors[p.index] = lx.hsb(0, 0, 0);
}
}
rad += deltaMs * .025 * direction;
float x = model.xMax / 2 + cos(angle) * rad;
float y = model.yMax / 2 + sin(angle) * rad;
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
float b = dist(x,y,p.x,p.y);
if (b < 90) {
colors[p.index] = blendColor(
for(int i=0; i<towerSize ;i++)
{
t= model.towers.get(i);
- for(Point p : t.points)
+ for(LXPoint p : t.points)
{
if(p.y<towerParams.get(i).getValuef()*200)
{
public void clearALL()
{
- for(Point p : model.points)
+ for(LXPoint p : model.points)
{
colors[p.index] = 0;
}
public void doDraw(int c,long col)
{
Tower t= model.towers.get((int) c);
- for(Point p : t.points)
+ for(LXPoint p : t.points)
{
colors[p.index] = (int) col;
}
}
public void clearALL()
{
- for(Point p : model.points)
+ for(LXPoint p : model.points)
{
colors[p.index] = 0;
}
evalTurn(vCur.t2); evalTurn(vCur.t3);
}
- Point p1, p2; int i2;
+ LXPoint p1, p2; int i2;
int draw(int nAmount, SCPattern pat) {
int nFrom = (pos ) >> 12;
}
void run(double deltaMs){
- for(Point p: model.points){ colors[p.index]=0; }
+ for(LXPoint p: model.points){ colors[p.index]=0; }
for(int i=1; i<balls.length; i++){
if(millis() - balls[i].lastSeen < 1000) {
- for(Point p: model.points){
+ for(LXPoint p: model.points){
int x = int(balls[i].x * 255.0);
int y = int(balls[i].y * 127.0);
if(p.x < x+4 && p.x > x-4 && p.y < y+4 && p.y > y-4) { colors[p.index] = #FF0000; }
pret.pixels = ss.getScreenShotJNI2(x, y, w, h);
//for(int i=0; i<px.length; i++){ pret.pixels[i] = px[i]; }
//println(pret.get(10,10));
- for(Point p: model.points){
+ for(LXPoint p: model.points){
colors[p.index] = pret.get((int(p.x)/8)*8, 128-int(p.y));
}
}
float interp (float a, float b, float c) { return (1-a)*b + a*c; }
float randctr (float a) { return random(a) - a*.5; }
float min (float a, float b, float c, float d) { return min(min(a,b),min(c,d)); }
-float pointDist(Point p1, Point p2) { return dist(p1.x,p1.y,p1.z,p2.x,p2.y,p2.z); }
-float xyDist (Point p1, Point p2) { return dist(p1.x,p1.y,p2.x,p2.y); }
+float pointDist(LXPoint p1, LXPoint p2) { return dist(p1.x,p1.y,p1.z,p2.x,p2.y,p2.z); }
+float xyDist (LXPoint p1, LXPoint p2) { return dist(p1.x,p1.y,p2.x,p2.y); }
float distToSeg(float x, float y, float x1, float y1, float x2, float y2) {
float A = x - x1, B = y - y1, C = x2 - x1, D = y2 - y1;
float dot = A * C + B * D, len_sq = C * C + D * D;
float interpWv(float i, float[] vals) { return interp(i-floor(i), vals[floor(i)], vals[ceil(i)]); }
void setNorm (PVector vec) { vec.set(vec.x/mMax.x, vec.y/mMax.y, vec.z/mMax.z); }
void setRand (PVector vec) { vec.set(random(mMax.x), random(mMax.y), random(mMax.z)); }
- void setVec (PVector vec, Point p) { vec.set(p.x, p.y, p.z); }
+ void setVec (PVector vec, LXPoint p) { vec.set(p.x, p.y, p.z); }
void interpolate(float i, PVector a, PVector b) { a.set(interp(i,a.x,b.x), interp(i,a.y,b.y), interp(i,a.z,b.z)); }
void StartRun(double deltaMs) { }
float val (BasicParameter p) { return p.getValuef(); }
xWaveNz[i] = wvAmp * (noise(i/(mMax.y*.3)-(1e3+NoiseMove)/1500.) - .5) * (mMax.x/2.);
}
- for (Point p : model.points) { nPoint++;
+ for (LXPoint p : model.points) { nPoint++;
setVec(P,p);
P.sub(modmin);
P.sub(pTrans);
int dir, ci; // dir -- 1 or -1.
// ci -- color index
- dVertex(Strip _s, Point _p) { s = _s; ci = _p.index; }
- Point getPoint(int i) { return s.points.get(dir>0 ? i : 15-i); }
+ dVertex(Strip _s, LXPoint _p) { s = _s; ci = _p.index; }
+ LXPoint getPoint(int i) { return s.points.get(dir>0 ? i : 15-i); }
void setOpp(dVertex _opp) { opp = _opp; dir = (ci < opp.ci ? 1 : -1); }
}
//----------------------------------------------------------------------------------------------------------------------------------
if (v0.t3 == null) { v0.t3=t; return; }
}
float dist2 (Strip s1, int pos1, Strip s2, int pos2) { return pointDist(s1.points.get(pos1), s2.points.get(pos2)); }
- float pd2 (Point p1, float x, float y, float z) { return dist(p1.x,p1.y,p1.z,x,y,z); }
+ float pd2 (LXPoint p1, float x, float y, float z) { return dist(p1.x,p1.y,p1.z,x,y,z); }
boolean sameSame (Strip s1, Strip s2) { return max(dist2(s1, 0, s2, 0), dist2(s1,15, s2,15)) < 5 ; } // same strut, same direction
boolean sameOpp (Strip s1, Strip s2) { return max(dist2(s1, 0, s2,15), dist2(s1,15, s2,0 )) < 5 ; } // same strut, opp direction
boolean sameBar (Strip s1, Strip s2) { return sameSame(s1,s2) || sameOpp(s1,s2); } // 2 strips on same strut
{
((Granim) g).update();
}
- List<Point> drawList = model.points.subList(Math.min(g.position,colors.length-1), Math.min(g.position + g.width(),colors.length-1));
+ List<LXPoint> drawList = model.points.subList(Math.min(g.position,colors.length-1), Math.min(g.position + g.width(),colors.length-1));
//println("drawlistsize "+drawList.size());
gbuffer = g.graphicBuffer.toArray(new Integer[0]);
Ring ring2 = new Ring((hue + hue_delta * 1) % 360, radius2, girth);
Ring ring3 = new Ring((hue + hue_delta * 2) % 360, radius3, girth);
- projection.reset(model)
+ projection.reset()
// Translate so the center of the car is the origin
- .translateCenter(model, 0, 0, 0);
+ .center();
for (Coord c : projection) {
//if (first_run) println(c.x + "," + c.y + "," + c.z);
float b = (millis() / 1200.f) % (2 * PI);
float g = (millis() / 1600.f) % (2 * PI);
- projection.reset(model)
+ projection.reset()
// Translate so the center of the car is the origin
- .translateCenter(model, 0, 0, 0);
+ .center();
for (Coord c : projection) {
// rotate3d(c, a, b, g);
float denominator = max(xAngle.getValuef() + yAngle.getValuef() + zAngle.getValuef(), 1);
- projection.reset(model)
+ projection.reset()
// Swim around the world
.rotate(rotation.getValuef(), xAngle.getValuef() / denominator, yAngle.getValuef() / denominator, zAngle.getValuef() / denominator)
- .translateCenter(model, 0, 50 + yPos.getValuef(), 0);
+ .translateCenter(0, 50 + yPos.getValuef(), 0);
float model_height = model.yMax - model.yMin;
float model_width = model.xMax - model.xMin;
float phase = phaseLFO.getValuef();
float crazy_factor = crazyParam.getValuef() / 0.2;
- projection.reset(model)
+ projection.reset()
.rotate(rotationZ.getValuef() * crazy_factor, 0, 1, 0)
.rotate(rotationX.getValuef() * crazy_factor, 0, 0, 1)
.rotate(rotationY.getValuef() * crazy_factor, 0, 1, 0);
float sf = 100. / (70 - 69.9*sat.getValuef());
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
float d = MAX_FLOAT;
if (p.y > model.cy) {
arm = tarm;
return;
}
float posf = position.getValuef();
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
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,
return;
}
float yVal = yPos.getValuef();
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
float falloff = 6 - 5*lightSize.getValuef();
float b = max(0, bVal - falloff*dist(p.x, p.y, xPos, yVal));
if (b > 0) {
float maxBright = sparkleBright * (1 - sparkle.getValuef());
for (Strip s : model.strips) {
int i = 0;
- for (Point p : s.points) {
+ for (LXPoint 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] = lx.hsb(
fPos = .2 + 4 * (.2 - fPos);
}
float falloff = 100. / (3 + sz.getValuef() * 36 + fPos * beatAmount.getValuef()*48);
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
int gi = (int) constrain((p.x - model.xMin) * NUM_DIVISIONS / (model.xMax - model.xMin), 0, NUM_DIVISIONS-1);
colors[p.index] = lx.hsb(
(lx.getBaseHuef() + abs(p.x - model.cx)*.8 + p.y*.4) % 360,
}
float pFalloff = (30 - 27*pSize.getValuef());
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
float b = 100 - pFalloff * (abs(p.x - x.getValuef()) + abs(p.y - y.getValuef()));
if (b > 0) {
colors[p.index] = blendColor(colors[p.index], lx.hsb(
float rng = (78 - 64 * range.getValuef()) / (model.yMax - model.cy);
float val = max(2, dbValue.getValuef());
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
int ci = (int) lerp(0, centers.length-1, (p.x - model.xMin) / (model.xMax - model.xMin));
float rFactor = 1.0 - 0.9 * abs(p.x - model.cx) / (model.xMax - model.cx);
colors[p.index] = lx.hsb(
float xv = xPos.getValuef();
float yv = yPos.getValuef();
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
float d = sqrt((p.x-xv)*(p.x-xv) + (p.y-yv)*(p.y-yv) + .1*(p.z-zPos)*(p.z-zPos));
float b = constrain(130 - falloff*d, 0, 100);
if (b > 0) {
int s = 0;
for (Strip strip : model.strips) {
int i = 0;
- for (Point p : strip.points) {
+ for (LXPoint p : strip.points) {
colors[p.index] = lx.hsb(
(lx.getBaseHuef() + 360 - p.x*.2 + p.y * .3) % 360,
constrain(.4 * min(abs(s - sVal1), abs(s - sVal2)), 20, 100),
SawLFO offset = new SawLFO(0, 1, 1000);
SinLFO rate = new SinLFO(350, 1200, 63000);
SinLFO falloff = new SinLFO(15, 50, 17000);
- SinLFO fX = new SinLFO(0, model.xMax, 19000);
- SinLFO fY = new SinLFO(0, model.yMax, 11000);
- SinLFO hOffX = new SinLFO(0, model.xMax, 13000);
+ SinLFO fX = new SinLFO(model.xMin, model.xMax, 19000);
+ SinLFO fY = new SinLFO(model.yMin, model.yMax, 11000);
+ SinLFO hOffX = new SinLFO(model.xMin, model.xMax, 13000);
public Swarm(GLucose glucose) {
super(glucose);
void run(double deltaMs) {
float s = 0;
- for (Strip strip : model.strips ) {
+ for (Strip strip : model.strips) {
int i = 0;
- for (Point p : strip.points) {
+ for (LXPoint p : strip.points) {
float fV = max(-1, 1 - dist(p.x/2., p.y, fX.getValuef()/2., fY.getValuef()) / 64.);
colors[p.index] = lx.hsb(
(lx.getBaseHuef() + 0.3 * abs(p.x - hOffX.getValuef())) % 360,
void computeBlend(int[] c1, int[] c2, double progress) {
float bleedf = 10 + bleed.getValuef() * 200.;
float xPos = (float) (-bleedf + progress * (model.xMax + bleedf));
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
float d = (p.x - xPos) / bleedf;
if (d < 0) {
colors[p.index] = c2[p.index];
float satBase = bassLevel*480*clr.getValuef();
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
int avgIndex = (int) constrain(1 + abs(p.x-model.cx)/(model.cx)*(eq.numBands-5), 0, eq.numBands-5);
float value = 0;
for (int i = avgIndex; i < avgIndex + 5; ++i) {
float edgeConst = 2 + 30*edge.getValuef();
float clrConst = 1.1 + clr.getValuef();
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
float avgIndex = constrain(2 + p.x / model.xMax * (eq.numBands-4), 0, eq.numBands-4);
int avgFloor = (int) avgIndex;
float falloffv = falloffv();
float satv = sat.getValuef() * 100;
float huev = lx.getBaseHuef();
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
colors[p.index] = blendColor(
colors[p.index],
lx.hsb(huev, satv, constrain(brightv - falloffv*abs(boom.getValuef() - dist(p.x, 2*p.y, 3*p.z, model.xMax/2, model.yMax, model.zMax*1.5)), 0, 100)),
float ywv = 100. / (10 + 40*yw.getValuef());
float zwv = 100. / (10 + 40*zw.getValuef());
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
color c = 0;
c = blendColor(c, lx.hsb(
(lx.getBaseHuef() + p.x/10 + p.y/3) % 360,
for (Strip strip : model.strips) {
int i = 0;
float mv = m[si % m.length].getValuef();
- for (Point p : strip.points) {
+ for (LXPoint p : strip.points) {
colors[p.index] = lx.hsb(
(hv + p.z + p.y*hs.getValuef()) % 360,
min(100, abs(p.x - s.getValuef())/2.),
float mv = m.getValuef();
int i = 0;
for (Strip strip : model.strips) {
- for (Point p : strip.points) {
+ for (LXPoint p : strip.points) {
colors[p.index] = lx.hsb(
(huev + i*constrain(cv, 0, 2) + p.z/2. + p.x/4.) % 360,
min(100, abs(p.y-sv)),
planes[1].run(deltaMs);
planes[2].run(deltaMs);
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
float d = MAX_FLOAT;
for (Plane plane : planes) {
if (plane.denom != 0) {
float cv = c.getValuef();
float dv = d.getValuef();
float denom = sqrt(av*av + bv*bv + cv*cv);
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
float d = abs(av*(p.x-model.cx) + bv*(p.y-model.cy) + cv*(p.z-model.cz) + dv) / denom;
colors[p.index] = lx.hsb(
(hv + abs(p.x-model.cx)*.6 + abs(p.y-model.cy)*.9 + abs(p.z - model.cz)) % 360,
bass[index] = rawBass * rawBass * rawBass * rawBass;
treble[index] = rawTreble * rawTreble;
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
int i = (int) constrain((model.xMax - p.x) / model.xMax * FRAME_WIDTH, 0, FRAME_WIDTH-1);
int pos = (index + FRAME_WIDTH - i) % FRAME_WIDTH;
}
}
+
h2.step(deltaMs);
calculateSpokes();
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
PVector pt = new PVector(p.x,p.y,p.z);
color h1c = h1.colorOfPoint(pt);
color h2c = h2.colorOfPoint(pt);
LXPattern[] patterns(GLucose glucose) {
return new LXPattern[] {
-
// Slee
new Cathedrals(glucose),
new MidiMusic(glucose),
new TestBassMapping(glucose),
new TestFloorMapping(glucose),
new TestSpeakerMapping(glucose),
- new TestPerformancePattern(glucose),
// new TestHuePattern(glucose),
// new TestXPattern(glucose),
// new TestYPattern(glucose),
for (Speaker speaker : model.speakers) {
for (Strip strip : speaker.strips) {
float b = 100;
- for (Point p : strip.points) {
+ for (LXPoint p : strip.points) {
colors[p.index] = lx.hsb(h % 360, 100, b);
b = max(0, b - 10);
}
int h = 0;
for (int si : strips) {
float b = 100;
- for (Point p : model.bassBox.strips.get(si).points) {
+ for (LXPoint p : model.bassBox.strips.get(si).points) {
colors[p.index] = lx.hsb(h % 360, 100, b);
b = max(0, b - 10);
}
int h = 0;
for (int si : strutIndices) {
float b = 100;
- for (Point p : model.bassBox.struts.get(si).points) {
+ for (LXPoint p : model.bassBox.struts.get(si).points) {
colors[p.index] = lx.hsb(h % 360, 100, b);
b = max(0, b - 10);
}
h = 0;
for (int fi : floorIndices) {
float b = 100;
- for (Point p : model.boothFloor.strips.get(fi).points) {
+ for (LXPoint p : model.boothFloor.strips.get(fi).points) {
colors[p.index] = lx.hsb(h, 100, b);
b = max(0, b - 3);
}
}
}
-class TestPerformancePattern extends TestPattern {
-
- final BasicParameter ops = new BasicParameter("OPS", 0);
- final BasicParameter iter = new BasicParameter("ITER", 0);
-
- TestPerformancePattern(GLucose glucose) {
- super(glucose);
- addParameter(ops);
- addParameter(iter);
- }
-
- public void run(double deltaMs) {
- float x = 1;
- for (int j = 0; j < ops.getValuef() * 400000; ++j) {
- x *= random(0, 1);
- }
-
- if (iter.getValuef() < 0.25) {
- for (Point p : model.points) {
- colors[p.index] = lx.hsb(
- (p.x*.1 + p.y*.1) % 360,
- 100,
- 100
- );
- }
- } else if (iter.getValuef() < 0.5) {
- for (int i = 0; i < colors.length; ++i) {
- colors[i] = lx.hsb(
- (90 + model.px[i]*.1 + model.py[i]*.1) % 360,
- 100,
- 100
- );
- }
- } else if (iter.getValuef() < 0.75) {
- for (int i = 0; i < colors.length; ++i) {
- colors[i] = lx.hsb(
- (180 + model.p[3*i]*.1 + model.p[3*i+1]*.1) % 360,
- 100,
- 100
- );
- }
- } else {
- for (int i = 0; i < colors.length; ++i) {
- colors[i] = lx.hsb(
- (270 + model.x(i)*.1 + model.y(i)*.1) % 360,
- 100,
- 100
- );
- }
- }
- }
-}
-
class TestStripPattern extends TestPattern {
SinLFO d = new SinLFO(4, 40, 4000);
public void run(double deltaMs) {
for (Strip s : model.strips) {
- for (Point p : s.points) {
+ for (LXPoint p : s.points) {
colors[p.index] = lx.hsb(
lx.getBaseHuef(),
100,
}
public void run(double deltaMs) {
float hv = lx.getBaseHuef();
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
// This is a common technique for modulating brightness.
// You can use abs() to determine the distance between two
// values. The further away this point is from an exact
}
public void run(double deltaMs) {
float hv = lx.getBaseHuef();
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
float bv = max(0, 100 - abs(p.y - yPos.getValuef()));
colors[p.index] = lx.hsb(hv, 100, bv);
}
}
public void run(double deltaMs) {
float hv = lx.getBaseHuef();
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
float bv = max(0, 100 - abs(p.z - zPos.getValuef()));
colors[p.index] = lx.hsb(hv, 100, bv);
}
public void run(double deltaMs) {
int ti = 0;
for (Tower t : model.towers) {
- for (Point p : t.points) {
+ for (LXPoint p : t.points) {
colors[p.index] = lx.hsb(
lx.getBaseHuef(),
100,
// For the same reasons described above, it may logically feel to you that
// some of these operations are in reverse order. Again, just keep in mind that
// the car itself is what's moving, not the object
- projection.reset(model)
+ projection.reset()
// Translate so the center of the car is the origin, offset by yPos
- .translateCenter(model, 0, yPos.getValuef(), 0)
+ .translateCenter(0, yPos.getValuef(), 0)
// Rotate around the origin (now the center of the car) about an X-vector
.rotate(angle.getValuef(), 1, 0, 0)
public void run(double deltaMs) {
for (Cube c : model.cubes) {
int i = 0;
- for (Point p : c.points) {
+ for (LXPoint p : c.points) {
colors[p.index] = lx.hsb(
lx.getBaseHuef(),
100,
spheres[0].radius = 100 * hueParameter.getValuef();
spheres[1].radius = 100 * hueParameter.getValuef();
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
float value = 0;
color c = lx.hsb(0, 0, 0);
return distanceTo(v.x, v.y, v.z);
}
- float distanceTo(Point p) {
+ float distanceTo(LXPoint p) {
return distanceTo(p.x, p.y, p.z);
}
raindrops.add(new Raindrop());
}
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
color c =
blendColor(
lx.hsb(210, 20, (float)Math.max(0, 1 - Math.pow((model.yMax - p.y) / 10, 2)) * 50),
flashes.add(new CubeFlash());
}
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
colors[p.index] = 0;
}
for (CubeFlash flash : flashes) {
float hue = (hueParameter.getValuef() + (hueVarianceParameter.getValuef() * flash.hue)) % 1.0;
color c = lx.hsb(hue * 360, saturationParameter.getValuef() * 100, (flash.value) * 100);
- for (Point p : flash.c.points) {
+ for (LXPoint p : flash.c.points) {
colors[p.index] = c;
}
}
Vector3 normalizedPoint = new Vector3();
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
if (random(1.0) < derez) {
continue;
}
float zSlope = (zSlopeParameter.getValuef() - 0.5) * 2;
int i = -1;
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
++i;
int value = 0;
* it but there may be useful code here.
*/
class TimTrace extends SCPattern {
- private Map<Point, List<Point>> pointToNeighbors;
- private Map<Point, Strip> pointToStrip;
+ private Map<LXPoint, List<LXPoint>> pointToNeighbors;
+ private Map<LXPoint, Strip> pointToStrip;
// private final Map<Strip, List<Strip>> stripToNearbyStrips;
int extraMs;
class MovingPoint {
- Point currentPoint;
+ LXPoint currentPoint;
float hue;
private Strip currentStrip;
private int currentStripIndex;
private int direction; // +1 or -1
- MovingPoint(Point p) {
+ MovingPoint(LXPoint p) {
this.setPointOnNewStrip(p);
hue = random(360);
}
- private void setPointOnNewStrip(Point p) {
+ private void setPointOnNewStrip(LXPoint p) {
this.currentPoint = p;
this.currentStrip = pointToStrip.get(p);
for (int i = 0; i < this.currentStrip.points.size(); ++i) {
}
void step() {
- List<Point> neighborsOnOtherStrips = pointToNeighbors.get(this.currentPoint);
+ List<LXPoint> neighborsOnOtherStrips = pointToNeighbors.get(this.currentPoint);
- Point nextPointOnCurrentStrip = null;
+ LXPoint nextPointOnCurrentStrip = null;
this.currentStripIndex += this.direction;
if (this.currentStripIndex >= 0 && this.currentStripIndex < this.currentStrip.points.size()) {
nextPointOnCurrentStrip = this.currentStrip.points.get(this.currentStripIndex);
Map<Strip, Vector3> stripToCenter = new HashMap();
for (Strip s : model.strips) {
Vector3 v = new Vector3();
- for (Point p : s.points) {
+ for (LXPoint p : s.points) {
v.add(p.x, p.y, p.z);
}
v.divide(s.points.size());
return stripToNeighbors;
}
- private Map<Point, List<Point>> buildPointToNeighborsMap() {
- Map<Point, List<Point>> m = new HashMap();
+ private Map<LXPoint, List<LXPoint>> buildPointToNeighborsMap() {
+ Map<LXPoint, List<LXPoint>> m = new HashMap();
Map<Strip, List<Strip>> stripToNearbyStrips = this.buildStripToNearbyStripsMap();
for (Strip s : model.strips) {
List<Strip> nearbyStrips = stripToNearbyStrips.get(s);
- for (Point p : s.points) {
+ for (LXPoint p : s.points) {
Vector3 v = new Vector3(p.x, p.y, p.z);
- List<Point> neighbors = new ArrayList();
+ List<LXPoint> neighbors = new ArrayList();
for (Strip nearbyStrip : nearbyStrips) {
- Point closestPoint = null;
+ LXPoint closestPoint = null;
float closestPointDistance = 100000;
- for (Point nsp : nearbyStrip.points) {
+ for (LXPoint nsp : nearbyStrip.points) {
float distance = v.distanceTo(nsp.x, nsp.y, nsp.z);
if (closestPoint == null || distance < closestPointDistance) {
closestPoint = nsp;
return m;
}
- private Map<Point, Strip> buildPointToStripMap() {
- Map<Point, Strip> m = new HashMap();
+ private Map<LXPoint, Strip> buildPointToStripMap() {
+ Map<LXPoint, Strip> m = new HashMap();
for (Strip s : model.strips) {
- for (Point p : s.points) {
+ for (LXPoint p : s.points) {
m.put(p, s);
}
}
}
public void run(double deltaMs) {
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
color c = colors[p.index];
colors[p.index] = lx.hsb(lx.h(c), lx.s(c), lx.b(c) - 3);
}
}
public void run(double deltaMs) {
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
float hv = sin(dist(p.x + pos, p.y, 128.0, 128.0) / 8.0)
+ sin(dist(p.x, p.y, 64.0, 64.0) / 8.0)
+ sin(dist(p.x, p.y + pos / 7, 192.0, 64.0) / 7.0)
}
}
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
int x = max(0,(int(p.x)+int(p.z))%xm);
int y = constrain(ym-int(p.y),0,ym-1);
colors[p.index] = flameColor(intensity[x][y]);
boolean on = avgdist<30;
float hv = (lx.getBaseHuef()+colorOffset[i])%360;
float br = max(0,100-avgdist*4);
- for (Point p : strip.points) {
+ for (LXPoint p : strip.points) {
if (on && br>bright[p.index]) {
colors[p.index] = lx.hsb(hv,sat[i].getValuef(),br);
bright[p.index] = br;
for (int j=0; j<c.strips.size(); j++) {
Strip s = c.strips.get(j);
if (j%4!=0 && j%4!=2) {
- for (Point p : s.points) {
+ for (LXPoint p : s.points) {
int seq = int(p.y*avgSize/model.yMax+pos.getValuef()+sin(p.x+p.z)*2)%avgSize;
seq=min(abs(seq-(avgSize/2)),avgSize-1);
colors[p.index] = lx.hsb(200,max(0,100-abs(p.x-col1.getValuef())/2),lightVals[seq]);
int i=0;
for (Strip s : model.strips) {
i++;
- for (Point p : s.points) {
+ for (LXPoint p : s.points) {
float dx, dz;
if (i%32 < 16) {
dx = p.x - (s.cx+xosc.getValuef());
for (int j=0; j<c.strips.size(); j++) {
Strip s = c.strips.get(j);
if (j%4!=0 && j%4!=2) {
- for (Point p : s.points) {
+ for (LXPoint p : s.points) {
float dis = (abs(p.x-model.xMax/2)+pos.getValuef())%model.xMax/2;
int seq = int((dis*avgSize*2)/model.xMax);
if (seq>avgSize) seq=avgSize-seq;
if (state != DEBUG_STATE_ANIM) {
color debugColor = (state == DEBUG_STATE_WHITE) ? white : off;
Cube cube = glucose.model.getCubeByRawIndex(rawCubeIndex);
- for (Point p : cube.points) {
+ for (LXPoint p : cube.points) {
colors[p.index] = debugColor;
}
}
if (state != DEBUG_STATE_ANIM) {
color debugColor = (state == DEBUG_STATE_WHITE) ? white : off;
for (Strip s : glucose.model.bassBox.boxStrips) {
- for (Point p : s.points) {
+ for (LXPoint p : s.points) {
colors[p.index] = debugColor;
}
}
state = debugState[channelIndex][1];
if (state != DEBUG_STATE_ANIM) {
color debugColor = (state == DEBUG_STATE_WHITE) ? white : off;
- for (Point p : glucose.model.boothFloor.points) {
+ for (LXPoint p : glucose.model.boothFloor.points) {
colors[p.index] = debugColor;
}
for (Strip s : glucose.model.bassBox.struts) {
- for (Point p : s.points) {
+ for (LXPoint p : s.points) {
colors[p.index] = debugColor;
}
}
state = debugState[channelIndex][1];
if (state != DEBUG_STATE_ANIM) {
color debugColor = (state == DEBUG_STATE_WHITE) ? white : off;
- for (Point p : glucose.model.speakers.get(channel.objectIndices[0]).points) {
+ for (LXPoint p : glucose.model.speakers.get(channel.objectIndices[0]).points) {
colors[p.index] = debugColor;
}
}
lx = glucose.lx;
lx.enableKeyboardTempo();
logTime("Built GLucose engine");
-
+
// Set the patterns
LXEngine engine = lx.engine;
engine.setPatterns(patterns = _leftPatterns(glucose));
}
void drawSimulation(color[] simulationColors) {
- camera(
+ camera(
eyeX, eyeY, eyeZ,
midX, midY, midZ,
0, -1, 0
noFill();
strokeWeight(2);
beginShape(POINTS);
- for (Point p : glucose.model.points) {
+ for (LXPoint p : glucose.model.points) {
stroke(simulationColors[p.index]);
vertex(p.x, p.y, p.z);
}
tower.add(cubes[cubeIndex++] = new Cube(st.x, st.y + CH* 4/3.*i, st.z, 0, st.r, 0, w));
}
towerList.add(new Tower(tower));
- }
+ }
return new Model(towerList, cubes, bassBox, speakers);
}
objectIndices[i] = (i < rawObjectIndices.length) ? rawObjectIndices[i] : NO_OBJECT;
}
}
-}
\ No newline at end of file
+}
private int mapStrip(Strip s, int direction, int[] points, int pi) {
if (direction == FORWARD) {
- for (Point p : s.points) {
+ for (LXPoint p : s.points) {
points[pi++] = p.index;
}
} else if (direction == BACKWARD) {