The node-garden animation nodes go back and forth on a straight line.
Node Garden is a creative coding classic.
It's a creative coding example made with the 'Processing'.
I got the motivation to make this Node Garden animation from the article of おかず(@okazz_).
ProcessingでGenerative art #65
https://note.mu/outburst/n/n990dcd4a8b1e
At first, I rotated these nodes. But it moves too fast to make the loop animation on Twitter.
— deconbatch (@deconbatch) January 11, 2019
So, I made them go back and forth on a straight line. And it worked.
The 'Processing' example Code.
Please feel free to use this example codeunder the terms of the GPL. To see other works based on my code is my pleasure. And my honor.
This code does not display any images on the screen but generates image files for animation. You can make an animation with these files.
// 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); } 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()); } } } /* 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/> */
Yet another example images.