Datasheet

{
size(500, 500, P3D);
colorMode(HSB, 100);
texture = loadImage("ring.png");
opc = new OPC(this, "127.0.0.1", 7890);
opc.ledGrid8x8(0, width/2, height/2, height / 16.0, 0, false);
// We can have up to 100 rings. They all start out invisible.
rings = new Ring[100];
for (int i = 0; i < rings.length; i++) {
rings[i] = new Ring();
}
}
void draw()
{
background(0);
// Smooth out the mouse location. The smoothX and smoothY variables
// move toward the mouse without changing abruptly.
float prevX = smoothX;
float prevY = smoothY;
smoothX += (mouseX - smoothX) * 0.1;
smoothY += (mouseY - smoothY) * 0.1;
// At every frame, randomly respawn one ring
rings[int(random(rings.length))].respawn(prevX, prevY, smoothX, smoothY);
// Give each ring a chance to redraw and update
for (int i = 0; i < rings.length; i++) {
rings[i].draw();
}
}
And that's it! You can see the complete source code for this example (http://adafru.it/cWe)
in GitHub.
© Adafruit Industries https://learn.adafruit.com/led-art-with-fadecandy Page 55 of 60