Come to My Garden : Feel the pulsation of flowers.

Wednesday, December 30, 2020
An example image of this animation with my custom noise.

A remodeled version of the animation with my custom noise.

This is the creative coding animation code written in Processing. It creates an animation of the pulsating flower.

It's a remodeled version of 'Interstellar Overdrive'. When I looked at the source code of 'Interstellar Overdrive' again, I felt it is terrible, and I wanted to recreate it. I simplified the code and made another animation work.

At first, I made this spiral figure.

An example image of this animation with my custom noise.

And I felt something lacking. So I added this background image. These three curves like vine are from 'Heard It Through The Grapevine'.

An example image of this animation with my custom noise.

An example source code of Processing.

This code does not display any images on the screen but generates image files in frames directory. You can make an animation with these files.

Please feel free to use this example code. To see other works based on my code is my pleasure. And my honor.


/**
 * Come to My Garden.
 * 
 *
 * @author @deconbatch
 * @version 0.1
 * @license GPL Version 3 http://www.gnu.org/licenses/
 * Processing 3.5.3
 * 2020.12.30
 */

void setup() {
  size(720, 720, P2D);
  colorMode(HSB, 360.0, 100.0, 100.0, 100.0);
  imageMode(CENTER);
  rectMode(CENTER);
  smooth();
  noLoop();
}

void draw() {
  int   frmMax    = 24 * 8;
  float speed     = 0.01;
  float thetaMax  = PI * 34.0; //68;
  float thetaDiv  = PI * 0.0015;
  float thetaMult = random(3.675, 3.75);
  float noiseBase = random(thetaMax);
  float hueBase   = random(360.0);

  // get background
  PImage bg = getBackground(width, height);

  translate(width * 0.5, height * 0.5);
  for (int frmCnt = 0; frmCnt < frmMax; frmCnt++) {

    float radiusBase = 5.0;
    float radiusDiv  = 0.0002;
    float frmRatio   = map(frmCnt, 0, frmMax, 0.0, 1.0);

    // draw background
    background(0.0, 0.0, 90.0, 100.0);
    image(bg, 0, 0);

    // draw foreground
    pushMatrix();
    noFill();
    beginShape();
    for (float theta = 0.0; theta < thetaMax; theta += thetaDiv) {
      radiusBase += radiusBase * radiusDiv;
      float nParam = noiseBase + theta * thetaMult + frmRatio * speed;
      float radius = radiusBase * map(customNoise(nParam), -1.0, 1.0, 0.85, 1.15);

      // position
      float ePtX = radius * cos(theta);
      float ePtY = radius * sin(theta);
      // color
      float eHue = (360.0 + hueBase + sin(theta * 0.25) * 60.0 + map(radius, 0.0, width * 0.5, 0.0, 120.0)) % 360.0;
      float eSat = map(radius, 0.0, width * 0.5, 80.0, 40.0);
      float eBri = map(radius, 0.0, width * 0.5, 60.0, 90.0);
      float eSiz = map(radius, 0.0, width * 0.5, 0.5, 4.0);
      
      strokeWeight(eSiz);
      stroke(eHue, eSat, eBri, 100.0);
      vertex(ePtX, ePtY);
    }
    endShape();
    popMatrix();

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

/**
 * customNoise : returns custom noise value
 */
private float customNoise(float value) {
  return pow(sin(value), 3) * cos(pow(value, 2));
}

/**
 * getBackground : returns background image
 */
private PImage getBackground(int _w, int _h) {
  PGraphics p = createGraphics(_w, _h);
  p.beginDraw();
  p.colorMode(HSB, 360, 100, 100, 100);
  p.background(0.0, 0.0, 90.0, 100.0);
  p.translate(width * 0.5, height * 0.5);

  // matrix
  p.pushMatrix();
  p.rotate(PI * 0.25);
  p.noFill();
  p.stroke(0.0, 0.0, 100.0, 100.0);
  p.strokeWeight(1.0);
  for (int x = -width; x < width; x += 20) {
    p.line(x, -height, x, height);
  }
  for (int y = -height; y < height; y += 20) {
    p.line(-width, y, width, y);
  }
  p.popMatrix();

  // vine
  p.noStroke();
  p.pushMatrix();
  p.rotate(-PI * 0.2);
  for (int plant = 0; plant < 3; ++plant) {
    int   lenMax   = 120;
    float boldness = 46.0;
    float step     = 4.0 + 1.0 * plant;
    p.rotate(TWO_PI / 3.0);
    p.pushMatrix();
    for (int len = 0; len < lenMax; len += 1) {
      float applySiz = boldness * (1.0 - abs(map(len, 0, lenMax, -0.8, 0.8)));
      p.translate(step, step);
      p.rotate(PI * len * 0.0005);
      p.fill(0.0, 0.0, 96.0, 100.0);
      p.ellipse(0, 0, applySiz, applySiz);
    }
    p.popMatrix();
  }
  p.popMatrix();
  p.endDraw();
  return p;
}

/**
 * casing : draw fancy casing
 */
private void casing() {
  fill(0.0, 0.0, 0.0, 0.0);
  strokeWeight(54.0);
  stroke(0.0, 0.0, 0.0, 100.0);
  rect(0.0, 0.0, width, height);
  strokeWeight(50.0);
  stroke(0.0, 0.0, 100.0, 100.0);
  rect(0.0, 0.0, width, height);
  noStroke();
  noFill();
  noStroke();
}


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

An example image of this animation with my custom noise.

An example image of this animation with my custom noise.

An example image of this animation with my custom noise.

 

 

Comments

No comments :

Post a Comment