Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import fiveagon.layout.*;
- import java.util.Random;
- color[] palette = { #2537b5, #ff3804 };
- Random random;
- Layout layout; // Custom layout class. Every call to x() gets the next point
- int dotCounter;
- int dotSize = 12;
- int gridSpace = 7;
- int totalDots = DragonCurve.numPoints(12); // Number of points for n-generations
- int dotsPerFrame = 5;
- boolean savingFrames = false;
- void setup() {
- size(540, 540);
- noStroke();
- createLayout();
- if (savingFrames) {
- saveFrame(frameName()); // Save black background as 0-th frame
- }
- }
- void draw() {
- blendMode(ADD);
- translate(width/3, height/3);
- if (dotCounter < totalDots) {
- for (int d = 0; d < dotsPerFrame; d++) {
- fill(randomColor(palette));
- ellipse(layout.x(), layout.y(), dotSize, dotSize);
- dotCounter++;
- }
- if (savingFrames) {
- saveFrame(frameName());
- }
- } else {
- if (savingFrames) {
- exit();
- }
- createLayout(); // Start all over
- }
- }
- void createLayout() {
- layout = new DragonCurve(gridSpace);
- //layout = new SacksSpiral(gridSpace);
- //layout = new VogelSpiral(0, gridSpace);
- dotCounter = 0;
- random = new Random(0);
- background(#000000);
- }
- color randomColor(color[] c) {
- int i = random.nextInt(c.length);
- return c[i];
- }
- String frameName() {
- return "frames4\\dragonCurve-###.tif";
- }
Advertisement
Add Comment
Please, Sign In to add comment