X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=DanHorwitz.pde;h=856c579a2e8ac7c7a14ce809b378abea3e4980d9;hb=7697e5c66da5c072999806ab87791c287c2c4811;hp=ca829ee6e893c31abe9514d432e09f9b557bbb99;hpb=a41f334c045811daef7e319214da557b5e48143a;p=SugarCubes.git diff --git a/DanHorwitz.pde b/DanHorwitz.pde index ca829ee..856c579 100644 --- a/DanHorwitz.pde +++ b/DanHorwitz.pde @@ -134,7 +134,7 @@ public class Noise extends DPat b += n.den/100 -.4 + pDensity.Val() -1; b += transAdd; - c = blendColor(c,lx.hsb(n.hue,100*n.sat,c1c(b)),ADD); + c = blendColor(c,color(n.hue,100*n.sat,c1c(b)),ADD); } return c; } @@ -184,9 +184,9 @@ public class Play extends DPat pRadius = addParam("Rad" , .1 ); pBounce = addParam("Bnc" , .2 ); pAmp = addParam("Amp" , .2 ); - pTempoMult = addPick ("TMult" , 0 , 5 , new String[] {"1x", "2x", "4x", "8x", "16x", "Rand" } ); - pTimePattern= addPick ("TPat" , 6 , 7 , new String[] {"Bounce", "Sin", "Roll", "Quant", "Accel", "Deccel", "Slide", "Rand"} ); - pShape = addPick ("Shape" , 3 , 15 , new String[] {"Line", "Tap", "V", "RandV", + pTempoMult = addPick ("TMult" , 5 , 5 , new String[] {"1x", "2x", "4x", "8x", "16x", "Rand" } ); + pTimePattern= addPick ("TPat" , 7 , 7 , new String[] {"Bounce", "Sin", "Roll", "Quant", "Accel", "Deccel", "Slide", "Rand"} ); + pShape = addPick ("Shape" , 7 , 15 , new String[] {"Line", "Tap", "V", "RandV", "Pyramid", "Wings", "W2", "Clock", "Triangle", "Quad", "Sphere", "Cone", "Noise", "Wave", "?", "?"} ); @@ -354,218 +354,194 @@ public class Play extends DPat // 12- TRB, B (r), BRB, R (b) // Back, Down, Fwd , Up // 1->7, 15->9 -class dBolt { - dStrip v, h; - int vpos, hpos; - dBolt(dStrip _v, dStrip _h, int _vpos, int _hpos) { - v=_v; h=_h; vpos=_vpos; hpos=_hpos; - if (v.b0 == null) { v.b0=this; h.b0=this; } - else { v.b1=this; h.b1=this; } - } -} - -class dVertex { - dStrip s1 , s2 ; - int dir1, dir2 ; - dVertex(dStrip s, int d) { - int _a = (s.iS%4==1)? (d==1? 5: 3) : - (s.iS%4==3)? (d==1? 9:11) : - (d==1) ? (s.Top()?4:12) : (s.Top()?12:4); - dir1 = d * (s.isVert() ? -1 : 1); - dir2 = d; - s1 = DL_.DS[s.iCube() + ((s.iS+_a) % 16)]; - s2 = DL_.DS[d == 1 ? (s.idx == s.iFace()+3 ? s.idx-3 : s.idx+1): - (s.idx == s.iFace() ? s.idx+3 : s.idx-1)]; - swapout(1 , 6); - swapout(15,-6); - } - void swapout(int a, int b) { - if (s1.iS == a) { s1 = DL_.DS[s1.idx + b]; dir1 = -dir1; } - if (s2.iS == a) { s2 = DL_.DS[s2.idx + b]; dir2 = -dir2; } - } - -} +int randDir() { return round(random(1))*2-1; } +//---------------------------------------------------------------------------------------------------------------------------------- +boolean dDebug = true; +class dCursor { + dVertex vCur, vNext, vDest; + float destSpeed; + int posStop, pos,posNext; // 0 - 65535 + color clr; -class dStrip { // THIS WAS SUCH A PAIN! - int row, col, ci, idx, iS, axis; // 1-y, 2-left, 3-right - Strip s; - boolean bTop; // direction: top ccw, bottom cw. - - boolean Top (){ return axis!=1 && bTop ; } - boolean Bottom(){ return axis!=1 && !bTop; } - boolean isVert(){ return axis==1; } - boolean isHorz(){ return axis!=1; } - int iCube (){ return 16*floor(idx/16); } - int iFace (){ return iCube() + 4*floor(iS/4); } - - void init(Strip _s, int _i, int _row, int _col) { - idx = _i; row = _row; col = _col; s = _s; - iS = idx%16; bTop = (iS%4==0); - ci = s.points.get(0).index; - DL_.DQ[col][row] = iCube(); - switch (iS) { - case 4: case 6 : case 12: case 14: axis=2; break; - case 0: case 2 : case 8 : case 10: axis=3; break; - default: axis=1; break; + dCursor() {} + + boolean isDone () { return pos==posStop; } + boolean atDest () { return vCur.s==vDest.s || + PointDist(vCur.getPoint(0), vDest.getPoint(0)) < 12 || + PointDist(vCur.getPoint(0), vDest.getPoint(15))< 12;} + void setCur (dVertex _v, int _p) { p2=null; vCur=_v; pos=_p; PickNext(); } + void setCur (dPixel _p) { setCur(_p.v, _p.pos); } + void setNext (dVertex _v, int _p, int _s) { vNext = _v; posNext = _p<<12; posStop = _s<<12; } + void setDest (dVertex _v, float _speed) { vDest = _v; destSpeed = _speed; } + void onDone () { setCur(vNext, posNext); PickNext(); } + + float minDist; + int nTurns; + boolean bRandEval; + + void Evaluate(dVertex v, int p, int s) { + if (v == null) return; ++nTurns; + if (bRandEval) { + if (random(nTurns) < 1) setNext(v,p,s); return; } + else { + float d = PointDist(v.getPoint(15), vDest.getPoint(0)); + if (d < minDist) { minDist=d; setNext(v,p,s); } + if (d == minDist && random(2)<1) { minDist=d; setNext(v,p,s); } } } - void addBolts() { - v0 = new dVertex(this, 1); - v1 = new dVertex(this,-1); + void EvalTurn(dTurn t) { + if (t == null || t.pos0<<12 <= pos) return; + Evaluate(t.v , t.pos1, t.pos0); + Evaluate(t.v.opp, 16-t.pos1, t.pos0); + } + void PickNext() { + bRandEval = random(.05+destSpeed) < .05; minDist=500; nTurns=0; + Evaluate(vCur.c0, 0, 16); Evaluate(vCur.c1, 0, 16); + EvalTurn(vCur.t0); EvalTurn(vCur.t1); + } - if (iS == 7 && col != 0 && row != 0) // left bottom - new dBolt(this, DL_.GetStrip(row-1,col-1,(col % 2 == 1) ? 8 : 12), - 4, (col % 2 == 1) ? 6 : 9); + Point p1, p2; int i2; - if (iS == 7 && col != 0 && row < MaxCubeHeight*2-2) // left top - new dBolt(this, DL_.GetStrip(row+1,col-1,(col % 2 == 1) ? 10 : 14), - 11, (col % 2 == 1) ? 9 : 6); + int draw(int nAmount, SCPattern pat) { + int nFrom = (pos ) >> 12; + int nMv = min(nAmount, posStop-pos); + int nTo = min(15,(pos+nMv) >> 12); + dVertex v = vCur; - if (iS == 9 && col < NumBackTowers-1 && row < MaxCubeHeight*2-2) // right top - new dBolt(this, DL_.GetStrip(row+1,col+1,(col % 2 == 1) ? 6 : 2), - 4, (col % 2 == 1) ? 6 : 9); + if (dDebug) { p1 = v.getPoint(nFrom); float d = (p2 == null ? 0 : PointDist(p1,p2)); if (d>5) { println("too wide! quitting: " + d); exit(); }} + for (int i = nFrom; i <= nTo; i++) { pat.getColors()[v.ci + v.dir*i ] = clr; } + if (v.same != null) for (int i = nFrom; i <= nTo; i++) { pat.getColors()[v.same.ci + v.same.dir*i] = clr; } - if (iS == 9 && col < NumBackTowers-1 && row != 0) // right bottom - new dBolt(this, DL_.GetStrip(row-1,col+1,(col % 2 == 1) ? 4 : 0), - 11, (col % 2 == 1) ? 9 : 6); - } + if (dDebug) { p2 = v.getPoint(nTo); i2 = nTo; } - dBolt b0, b1; - dVertex v0, v1; + pos += nMv; return nAmount - nMv; + } } -class dCursor { - dStrip s, sNext; - int nLast,pos,posNext,end; // 0 - 65535 - int dir; // 1 or -1 - color clr; - - dCursor(color _c) { clr=_c;} - - boolean isDone() { return pos==end; } - void set(dStrip _s, int _dir) { - s=_s; dir=_dir; pos = 0; end=65536; nLast=-1; sNext=null; +//---------------------------------------------------------------------------------------------------------------------------------- +class Worms extends SCPattern { + float StripsPerSec = 10; + float TrailTime = 3000; + int numCursors = 50; + ArrayList cur = new ArrayList(30); + + private GraphicEQ eq = null; + + private BasicParameter pBeat = new BasicParameter("BEAT", 0); + private BasicParameter pSpeed = new BasicParameter("FAST", .2); + private BasicParameter pBlur = new BasicParameter("BLUR", .3); + private BasicParameter pWorms = new BasicParameter("WRMS", .3); + private BasicParameter pConfusion = new BasicParameter("CONF", .1); + private BasicParameter pEQ = new BasicParameter("EQ" , 0); + private BasicParameter pSpawn = new BasicParameter("DIR" , 0); + + int zMidLat = 82; + float nConfusion; + private final Click moveChase = new Click(1000); + + xyz middle; + int AnimNum() { return floor(pSpawn.getValuef()*(4-.01)); } + float randX() { return random(model.xMax-model.xMin)+model.xMin; } + float randY() { return random(model.yMax-model.yMin)+model.yMin; } + xyz randEdge() { + return random(2) < 1 ? new xyz(random(2)<1 ? model.xMin:model.xMax, randY(), zMidLat) : + new xyz(randX(), random(2)<1 ? model.yMin:model.yMax, zMidLat) ; } - boolean MakeTurn(dBolt b) { - int nEnd= (s.isVert() ? b.vpos : b.hpos) <<12; - nEnd= (dir==1 ? nEnd : 65536-nEnd); - if (nEnd < pos) return false; - if (s.isVert()) { sNext = b.h; posNext = b.hpos<<12; end = nEnd; } - else { sNext = b.v; posNext = b.vpos<<12; end = nEnd; } - return true; + Worms(GLucose glucose) { + super(glucose); + addModulator(moveChase).start(); + addParameter(pBeat); addParameter(pSpeed); + addParameter(pBlur); addParameter(pWorms); + addParameter(pEQ); addParameter(pConfusion); + addParameter(pSpawn); + middle = new xyz(model.cx, model.cy, 71); + if (lattice == null) lattice = new dLattice(); + for (int i=0; i= MaxCubeHeight*2-1) { col++; row = (col%2==1)?1:0; } - if (col >= NumBackTowers) continue; - iTowerStrips++ ; - dStrip s = DS[iTowerStrips] = new dStrip(); - s.init(strip, iTowerStrips, row, col); - } + case 1: c.clr = lx.hsb(135,0,100); // top to bottom + float xLin = randX(); + c.setDest(lattice.getClosest(new xyz(xLin, 0 , zMidLat)).v, nConfusion); + c.setCur (lattice.getClosest(new xyz(xLin, model.yMax, zMidLat))); + break; - for (int j=0; j> 12); - int nTo = min(15,(c.pos+nAmount) >> 12); c.nLast=nTo; - int nMv = min(nAmount, c.end-c.pos); - c.pos += nMv; - for (int i = nFrom; i <= nTo; i++) { - int n = c.s.ci + (c.dir>0 ? i : 15-i); - colors[n] = c.clr; + void setNewDest() { + if (AnimNum() != 2) return; + xyz dest = new xyz(randX(), randY(), zMidLat); + for (int i=0; i 100) return; + if (moveChase.click()) setNewDest(); - Worms(GLucose glucose) { - super(glucose); - if (DL_ == null) DL_ = new dLattice(); - for (int i=0; i0) { // EQ + eq.run(deltaMs); + fBass = eq.getAverageLevel(0, 4); + fTreble = eq.getAverageLevel(eq.numBands-7, 7); + } - void run(double deltaMs) { - //Test Joints - if (false) { - for (int j=0; j= d.vpos) colors[d.v.ci+i] = lx.hsb(0,0,30); - if (s == d.h && i >= d.hpos) colors[d.h.ci+i] = lx.hsb(0,0,30); - }} - } - } else { - for (int i=0; i 0) { - nLeft = draw(cur[i], nLeft); - if (cur[i].isDone()) cur[i].PickNext(); - } + if (pBlur.getValuef() < 1) { // trails + for (int i=0,s=model.points.size(); i0) colors[i] = color(hue(c), saturation(c), (float)(b-100*deltaMs/(pBlur.getValuef()*TrailTime))); } + } - for (int i=0,s=model.points.size(); i0) colors[i] = lx.hsb(lx.h(c), lx.s(c), - max(0, (float)(b-100*deltaMs/TrailTime))); + int nWorms = floor(pWorms.getValuef() * numCursors * + map(pEQ.getValuef(),0,1,1,constrain(2*fTreble,0,1))); + + for (int i=0; i 0) { + nLeft = c.draw(nLeft,this); if (!c.isDone()) continue; + c.onDone(); if (c.atDest()) reset(c); } } } + + + public void onActive() { if (eq == null) { + eq = new GraphicEQ(lx, 16); eq.slope.setValue(0.6); + eq.level.setValue(0.65); eq.range.setValue(0.35); + eq.release.setValue(0.4); + }} } //----------------------------------------------------------------------------------------------------------------------------------