Making of some creative coding : A swirl of dust.

Generative art made with Processing.
Vertex example.

Generative art made with Processing.
Swirl of dust example.



First idea.

When I drew a line with this recurrence formula,
x += div * cos(TWO_PI * noise(sin(TWO_PI * n)) * amp);
y += div * sin(TWO_PI * noise(sin(TWO_PI * n)) * amp);

// div = 0.002;
// amp = 50.0;
// n : 0.0 to 1.0


It looks like something decoration of paper wallpaper.




Add Vector Field essence.

I tried to add individuality in each shape.
So I use the Vector Field method to determine the shapes.

Drawing vector field | GenerateMe
https://generateme.wordpress.com/2016/04/24/drawing-vector-field/

ns = noise(sin(TWO_PI * n), x, y)
x += div * cos(TWO_PI * ns * amp);
y += div * sin(TWO_PI * ns * amp);

// div = 0.002;
// amp = 50.0;
// n : 0.0 to 1.0



Generative art made with Processing.
Got a personality!





Make it cyclic.

And I animate these shapes.


And I wanted to make this animation cyclic.
Place them in a circle, move the right value of radian, then you can make these shape cyclic automatically with the Vector Field magic!

x[i] = r * cos(a[i] + TWO_PI * a / n);
y[i] = r * sin(a[i] + TWO_PI * a / n);

// i : 1 to n
// r : radius
// a : animate parameter 0.0 to 1.0
// n : shape number


If you draw shapes in individual colors, locations are correct but you can't see it cyclic animation.


If all shapes were in same color, it looks eternal cycle!


The Vector Field essence meets cyclic animation.





And more fun.

Make a circle to Archimedes' helicoid, then it looks like a eternal inlet (or outlet) port of dust.



Please feel free to use it, if you like it.
To see other works based on my code is my pleasure. And my honor.


/**
 * A swirl of dust.
 * This code does not display any images on screen but generates image files in frames directory.
 * You can make an animation with these files. 
 * 
 * @author @deconbatch
 * @version 0.1
 * Processing 3.2.1
 * created 2019.09.04
 *
 */

void setup() {

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

}

void draw() {

  int   frmMax   = 24 * 6; // 24fps x 6s frames
  int   ptnCnt   = 13;
  float plotDiv  = 0.002;
  float plotMult = 2.0;
  float baseHue  = random(360.0);
  float baseSat  = 80.0;
  float baseBri  = 60.0;
  float baseSiz  = 1.0;

  translate(width * 0.5, height * 0.5);

  for (int frmCnt = 1; frmCnt <= frmMax; ++frmCnt) {
    float frmRatio = map(frmCnt, 1, frmMax, 0.0, 1.0);
    float rDiv     = TWO_PI / ptnCnt;
    
    background(baseHue, 0.0, 90.0, 100);

    for (float rInit = 0.0; rInit < TWO_PI * 3.0; rInit += rDiv) {
      
      float rRatio = map(rInit, 0.0, TWO_PI * 3.0, 0.0, 1.0);
      fill(baseHue, baseSat * rRatio, baseBri * (1.0 - rRatio), 100.0);

      // make it cyclic
      float radius = (rInit - rDiv * frmRatio) * 0.03;
      float xInit  = radius * cos(rInit - rDiv * frmRatio);
      float yInit  = radius * sin(rInit - rDiv * frmRatio);

      // The Vector Field essence
      float nInit  = sin(xInit * 3.0 + yInit * 3.0);
      
      float xPoint  = xInit;
      float yPoint  = yInit;
      int   plotMax = floor(1000 * radius);
      for (int plotCnt = 0; plotCnt < plotMax; ++plotCnt) {

        float pRatio = map(plotCnt, 0, plotMax, 0.0, 1.0);
        float eSiz   = baseSiz * sin(PI * pRatio);
        float xPrev  = xPoint;
        float yPrev  = yPoint;
        float dInit  = dist(0.0, 0.0, xPrev, yPrev);
        float dNoise = customNoise(nInit, TWO_PI * pRatio) + customNoise(TWO_PI * pRatio, nInit);
          
        xPoint += plotDiv * cos(TWO_PI * dNoise * plotMult);
        yPoint += plotDiv * sin(TWO_PI * dNoise * plotMult);

        ellipse(xPoint * width, yPoint * height, eSiz, eSiz);

      }
    }      
    saveFrame("frames/" + String.format("%04d", frmCnt) + ".png");
  }

  exit();

}

/**
 * customNoise : returns -1.0 .. 1.0 almost random but interesting value
 */
float customNoise(float _x, float _y) {
  return pow(sin(_x), 3) * cos(pow(_y, 2));
}

/*
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 
*/




No comments :

Post a Comment