Let Me Roll It.

Beautiful swirl image that made with Processing.
An interesting swirl image that made with Processing.


Description.

A generative art work made with Processing (Java programming language).

It was made with the same idea of Let's Twist Again.
It's a kind of complex Lissajous figure I think.
It looks good in still image but not in animation.

Processing code example.

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



// Let Me Roll It.
// @author @deconbatch
// @version 0.1
// Processing 3.2.1
// 2018.10.08

void setup() {

  size(980, 980);
  colorMode(HSB, 360, 100, 100, 100);
  blendMode(SUBTRACT);
  rectMode(CENTER);
  smooth();
  noLoop();
  noStroke();

}

void draw() {

  int   frameCntMax = 3; // create 3 images
  float baseHue     = random(360);

  translate(width / 2, height / 2);

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

    float pA         = random(0.001, 0.01);
    float pB         = random(0.001, 0.01);
    float pC         = pB * random(0.2, 0.8);
    float divT       = random(0.1, 0.8);
    float divA       = random(0.00001, 0.0001) / divT;
    int   densityMax = 6000;
    int   lineCntMax = floor(divT * 100);

    baseHue += 120.0;
    background((baseHue + 150) % 360, 2, 95, 100);
    
    pushMatrix();
    rotate(random(PI));

    for (int lineCnt = 0; lineCnt < lineCntMax; ++lineCnt) {

      float prevX = 0.0;
      float prevY = 0.0;
      float pTime = 0.0;

      pA += divA;

      for (int density = 0; density < densityMax; ++density) {

        // calculate the shape
        float x =  sin(pA * prevX + pB * pTime) * cos(pA * pTime);
        float y =  cos(pA * prevY + pC * pTime) * sin(pA * pTime);

        float densityRatio = map(density % 1000, 0, 999, 0.0, 1.0);
        float size = densityRatio * 5.0;
        fill(
             (baseHue + densityRatio * 90.0) % 360,
             map(densityRatio, 0.0, 1.0, 50.0, 0.0),
             map(densityRatio, 0.0, 1.0, 10.0, 0.0),
             100
             );
        ellipse(
                x * width * 0.4,
                y * height * 0.4,
                size,
                size
                );

        prevX = x;
        prevY = y;
        pTime += divT;

      }

    }

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

  }

  exit();

}

void casing(float baseHue) {

  fill(0.0, 0.0, 0.0, 0.0);
  strokeWeight(40.0);
  stroke(baseHue % 360.0, 30.0, 95.0, 100.0);
  rect(0.0, 0.0, width, height);
  strokeWeight(30.0);
  stroke(0.0, 0.0, 90.0, 100.0);
  rect(0.0, 0.0, width, height);
  noStroke();

}

/*
Copyright (C) 2018- 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 
*/




Beautiful swirl image that made with Processing.

Creative coding makes interesting swirl image.

Interesting swirl image.


No comments :

Post a Comment