Dynamic Symmetry: Animating Linear Motion in the Node Garden

Beautiful polks dots and connected lines.


Evolution of a Classic: The Node Garden

This generative animation was developed in Processing, utilizing a refined "Node Garden" technique to create fascinating animation.

I was inspired to create this Node Garden animation after reading an article by @okazz_.

ProcessingでGenerative art #65
https://note.mu/outburst/n/n990dcd4a8b1e


Initially, I experimented with rotating the nodes. However, the motion was too frantic to create a clean, seamless loop for social media.


To fix this, I constrained the nodes to move back and forth along straight lines. This resulted in a much more rhythmic and hypnotic flow.

 

Implementation in Processing

The following script generates a series of high-resolution frames. And it does not display any images on the screen.
These frames can be compiled into a seamless animation, showcasing the rhythmic movement of the network.

This code is provided under the GPL license. Feel free to experiment with it—I would be honored to see any works inspired by this approach.

// Polka Dots and Moonbeams.
// @author @deconbatch
// @version 0.1
// Processing 3.2.1
// 2019.01.13

void setup() {

  size(720, 720);
  colorMode(HSB, 360, 100, 100, 100);
  smooth();
  noLoop();

}

void draw() {

  translate(width / 2, height / 2);

  int   frameCntMax  = 24 * 6;
  int   nodeCntMax   = 10;
  float limitLen     = width * 0.25;
  float baseHue      = random(360.0);
  float baseRotation = random(PI);

  Node [] nodes = new Node[nodeCntMax];
  for (int i = 0; i < nodeCntMax; ++i) {
    nodes[i] = new Node(baseHue);
  }

  for (int frameCnt = 0; frameCnt < frameCntMax; ++frameCnt) {

    float frameRatio = map(frameCnt, 0, frameCntMax, 0.0, 1.0);
    
    background(0.0, 0.0, 90.0, 100.0);
    pushMatrix();
    rotate(baseRotation);
    
    for (int nodeCnt = 0; nodeCnt < nodeCntMax; ++nodeCnt) {

      // shift start frame of easing with each node
      float easingRatio = easeInOutPow((frameRatio + nodeCnt * 1.0 / nodeCntMax) % 1.0);

      // animate each node
      float radius = map(
                         nodeCnt,
                         0,
                         nodeCntMax,
                         width * (0.1 + 0.4 * sin(PI * easingRatio)),
                         width * (0.5 - 0.5 * sin(PI * easingRatio))
                         );

      // initial location, using noise() as array of random()
      float radian = HALF_PI * nodeCnt * (1.0 + noise(nodeCnt));

      float x = radius * cos(radian);
      float y = radius * sin(radian);

      nodes[nodeCnt].setNode(x, y);

    }

    // draw lines
    for (int i = 0; i < nodeCntMax - 1; i++) {
      for (int j = i + 1; j < nodeCntMax; j++) {
        nodes[i].drawLine(nodes[j], limitLen);
      }
    }

    // draw dots
    for (int i = 0; i < nodeCntMax; i++) {
      nodes[i].drawDot();
    }

    popMatrix();
    casing(baseHue);
    saveFrame("frames/" + String.format("%04d", frameCnt) + ".png");

  }

  exit();

}

  
/**
 * easeInOutPow easing function.
 * @param  t     0.0 - 1.0 : linear value.
 * @return float 0.0 - 1.0 : eased value.
 */
private float easeInOutPow(float t) {
  return t * t;
}

/**
 * casing : draw fancy casing
 * @param  hueBase : casing color.
 */
private void casing(float baseHue) {

  rectMode(CENTER);
  fill(0.0, 0.0, 0.0, 0.0);
  strokeWeight(40.0);
  stroke(baseHue, 100.0, 10.0, 100.0);
  rect(0.0, 0.0, width, height);
  strokeWeight(30.0);
  stroke(0.0, 0.0, 100.0, 100.0);
  rect(0.0, 0.0, width, height);
  noStroke();

}

/**
 * Keeping node information. Drawint polka dot and line between nodes.
 * @param  baseHue 0.0 - 360.0 : draw points color.
 */
private class Node {

  private float nX, nY;
  private float nSize;
  private float nHue, nSat, nBri;

  Node(float basnHue) {

    nX    = 0.0;
    nY    = 0.0;
    nSize = 0.0;
    nHue  = (basnHue + random(60.0)) % 360.0;
    nSat  = random(30.0, 60.0);
    nBri  = random(60.0, 80.0);

  }

  public void setNode(float pX, float pY) {

    nX = pX;
    nY = pY;
    nSize = sqrt(dist(0.0, 0.0, pX, pY)) * 2.0;

  }

  public float getNodeX() {
    return nX;
  }

  public float getNodeY() {
    return nY;
  }

  /**
   * drawDot : draw two polka dots symmetrically.
   */
  public void drawDot() {

    strokeWeight(3.0);
    stroke(0.0, 0.0, 90.0, 100.0);
    fill(nHue, nSat, nBri, 100.0);
    ellipse(nX, nY, nSize, nSize);
    ellipse(-nX, -nY, nSize, nSize); //symmetric elegance

  }

  public void drawLine(Node toNode, float limitLen) {
  
    float distance = dist(nX, nY, toNode.getNodeX(), toNode.getNodeY());

    if (distance < limitLen) {
      strokeWeight(map(distance, 0.0, limitLen, 5.0, 0.2));
      stroke(
             nHue,
             map(distance, 0.0, limitLen, 0.0, 30.0),
             nBri,
             100
             );
      line(nX, nY, toNode.getNodeX(), toNode.getNodeY());
      line(-nX, -nY, -toNode.getNodeX(), -toNode.getNodeY()); //symmetric elegance

    }
  
  }

}

/*
Copyright (C) 2019- deconbatch

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>
*/


 

Visual Variations

Here are an additional example exploring different parameters within the Node Garden system.

Beautiful polks dots and connected lines.

 

Next Post Previous Post
No Comment
Add Comment
comment url