| 1 | class TestHuePattern extends SCPattern { |
| 2 | public TestHuePattern(GLucose glucose) { |
| 3 | super(glucose); |
| 4 | } |
| 5 | public void run(int deltaMs) { |
| 6 | for (int i = 0; i < colors.length; ++i) { |
| 7 | colors[i] = color(lx.getBaseHuef(), 100, 100); |
| 8 | } |
| 9 | } |
| 10 | } |
| 11 | |
| 12 | class TestXPattern extends SCPattern { |
| 13 | private SinLFO xPos = new SinLFO(0, model.xMax, 4000); |
| 14 | public TestXPattern(GLucose glucose) { |
| 15 | super(glucose); |
| 16 | addModulator(xPos).trigger(); |
| 17 | } |
| 18 | public void run(int deltaMs) { |
| 19 | for (Point p : model.points) { |
| 20 | colors[p.index] = color( |
| 21 | lx.getBaseHuef(), |
| 22 | 100, |
| 23 | max(0, 100 - abs(p.fx - xPos.getValuef())) |
| 24 | ); |
| 25 | } |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | class TestYPattern extends SCPattern { |
| 30 | private SinLFO yPos = new SinLFO(0, model.yMax, 4000); |
| 31 | public TestYPattern(GLucose glucose) { |
| 32 | super(glucose); |
| 33 | addModulator(yPos).trigger(); |
| 34 | } |
| 35 | public void run(int deltaMs) { |
| 36 | for (Point p : model.points) { |
| 37 | colors[p.index] = color( |
| 38 | lx.getBaseHuef(), |
| 39 | 100, |
| 40 | max(0, 100 - abs(p.fy - yPos.getValuef())) |
| 41 | ); |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | class TestZPattern extends SCPattern { |
| 47 | private SinLFO zPos = new SinLFO(0, model.zMax, 4000); |
| 48 | public TestZPattern(GLucose glucose) { |
| 49 | super(glucose); |
| 50 | addModulator(zPos).trigger(); |
| 51 | } |
| 52 | public void run(int deltaMs) { |
| 53 | for (Point p : model.points) { |
| 54 | colors[p.index] = color( |
| 55 | lx.getBaseHuef(), |
| 56 | 100, |
| 57 | max(0, 100 - abs(p.fz - zPos.getValuef())) |
| 58 | ); |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | class TestProjectionPattern extends SCPattern { |
| 64 | |
| 65 | final Projection projection; |
| 66 | final SawLFO angle = new SawLFO(0, TWO_PI, 9000); |
| 67 | final SinLFO yPos = new SinLFO(-20, 40, 5000); |
| 68 | |
| 69 | TestProjectionPattern(GLucose glucose) { |
| 70 | super(glucose); |
| 71 | projection = new Projection(model); |
| 72 | addModulator(angle).trigger(); |
| 73 | addModulator(yPos).trigger(); |
| 74 | } |
| 75 | |
| 76 | public void run(int deltaMs) { |
| 77 | // Note: logically, you typically apply the transformations in reverse order |
| 78 | projection.reset(model) |
| 79 | .translate(-model.xMax/2., -model.yMax/2. + yPos.getValuef(), -model.zMax/2.) |
| 80 | .rotate(angle.getValuef(), 1, 0, 0) |
| 81 | .scale(1, 1.5, 1); |
| 82 | |
| 83 | for (Coord c : projection) { |
| 84 | float d = sqrt(c.x*c.x + c.y*c.y + c.z*c.z); // distance from origin |
| 85 | // d = abs(d-60) + max(0, abs(c.z) - 20); // life saver / ring thing |
| 86 | d = max(0, abs(c.y) - 10 + .3*abs(c.z) + .08*abs(c.x)); // plane / spear thing |
| 87 | colors[c.index] = color( |
| 88 | (lx.getBaseHuef() + .6*abs(c.x) + abs(c.z)) % 360, |
| 89 | 100, |
| 90 | constrain(140 - 10*d, 0, 100) |
| 91 | ); |
| 92 | } |
| 93 | } |
| 94 | } |