X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=JackStahl.pde;fp=JackStahl.pde;h=543ab892b8ca0e44b47333a563a23cc10f908844;hb=9b37e50c388caa3cdb42b15eb6626c820eb09cc9;hp=05fbe3da27f2197bed833ff9e5916d0acd037e91;hpb=677f5e155dccb7690d2f14ee87f86add9070732b;p=SugarCubes.git diff --git a/JackStahl.pde b/JackStahl.pde index 05fbe3d..543ab89 100644 --- a/JackStahl.pde +++ b/JackStahl.pde @@ -78,10 +78,38 @@ class Breathe extends SCPattern { final BasicParameter hueScale = new BasicParameter("HUE", 0.3); + class Sphere { + float x, y, z; + float radius; + float hue; + } + + private final Sphere[] spheres; + private final float centerX, centerY, centerZ; + public Breathe(GLucose glucose) { super(glucose); addParameter(hueScale); + + spheres = new Sphere[2]; + centerX = (model.xMax + model.xMin) / 2; + centerY = (model.yMax + model.yMin) / 2; + centerZ = (model.zMax + model.zMin) / 2; + + + spheres[0] = new Sphere(); + spheres[0].x = model.xMin + 50; + spheres[0].y = centerY; + spheres[0].z = centerZ; + spheres[0].radius = 25; + + spheres[1] = new Sphere(); + spheres[1].x = model.xMax - 50; + spheres[1].y = centerY; + spheres[1].z = centerZ; + spheres[1].radius = 25; + } @@ -111,7 +139,18 @@ class Breathe extends SCPattern { float v1 = sin_x > y_in_range ? (100 + 100*(y_in_range - sin_x)) : 0; float hue_color = (lx.getBaseHuef() + hueScale.getValuef() * (abs(p.x-model.xMax/2.)*.6 + abs(p.y-model.yMax/2)*.9 + abs(p.z - model.zMax/2.))) % 360; - colors[p.index] = color(hue_color, 70, v1); + color c = color(hue_color, 70, v1); + + // Now draw the spheres + for (Sphere s : spheres) { + float phase_x = (s.x - phase * model_width / ( 2 * PI)) % model_width; + float d = sqrt(pow(p.x - phase_x, 2) + pow(p.y - s.y, 2) + pow(p.z - s.z, 2)); + float r = (s.radius); + float value = max(0, 1 - max(0, d - r) / 10); + + c = blendColor(c, color(hue_color + 180 % 360, 70, min(1, value) * 100), ADD); + } + colors[p.index] = c; } } }