--- /dev/null
+// Port of a pattern from Fadecandy. Micah Elizabeth Scott, November 2013.
+class Rings extends SCPattern {
+
+ float dx, dy, dz;
+ float angleParam, z, hue, satParam, spacingParam;
+ float dzParam, centerParam;
+
+ public Rings(GLucose glucose) {
+ super(glucose);
+ }
+
+ public void run(double deltaMs) {
+
+ float noiseScale = 0.02;
+ float speed = 0.002;
+ float zspeed = 0.04;
+ float scale = 1.0;
+
+ angleParam += (deltaMs * 0.001) % (2*PI);
+ float angle = sin(angleParam);
+
+ z += deltaMs * 0.0008;
+ hue += (deltaMs * 0.036) % 360;
+
+ satParam += deltaMs * 0.000122;
+ spacingParam += deltaMs * 0.000124;
+ dzParam += deltaMs * 0.000014;
+ centerParam += deltaMs * 0.000125;
+
+ float saturation = 100 * constrain(pow(1.9 * noise(satParam), 2.5), 0, 1);
+ float spacing = noise(spacingParam) * 50;
+
+ dx += cos(angle) * speed;
+ dy += sin(angle) * speed;
+ dz += (pow(noise(dzParam), 1.8) - 0.5) * zspeed;
+
+ float centerx = map(noise(centerParam, 100), 0, 1, -0.1, 1.1);
+ float centery = map(noise(centerParam, 200), 0, 1, -0.1, 1.1);
+ float centerz = map(noise(centerParam, 300), 0, 1, -0.1, 1.1);
+
+ float coordMin = min(model.xMin, min(model.yMin, model.zMin));
+ float coordMax = max(model.xMax, max(model.yMax, model.zMax));
+
+ for (LXPoint p : model.points) {
+
+ // Scale while preserving aspect ratio
+ float x = map(p.x, coordMin, coordMax, 0, 1);
+ float y = map(p.y, coordMin, coordMax, 0, 1);
+ float z = map(p.z, coordMin, coordMax, 0, 1);
+
+ float dist = sqrt(sq(x - centerx) + sq(y - centery) + sq(z - centerz));
+ float pulse = (sin(dz + dist * spacing) - 0.3) * 0.6;
+
+ noiseDetail(4);
+ float n = map(noise(dx + x*scale + pulse, dy + y*scale, dz + z*scale), 0, 1, -0.65, 1);
+ float m = map(noise(dx + x*scale, dy + y*scale, dz + z*scale), 0, 1, 0, 300);
+ noiseDetail(1);
+
+ colors[p.index] = lx.hsb(
+ (hue + m) % 360.0,
+ saturation,
+ 100 * constrain(pow(3.0 * n, 3.5), 0, 1.0)
+ );
+ }
+ }
+};