The Honey Roll.

Generative art made with Processing.
Generative art made with Processing.


Description of this creative coding work.

Creative coding works made with Processing.

I had an idea that draws sine wave and rotates with sine wave amplitude as an angle.
Once I used rotate() to rotate but vertex() did not work.

ellipse() and vertex()

points and line with vertex()

ellipse() and vertex() with rotate()

vertex() did not follow rotate()

So I calculated coordinate rotation by myself.

This code does not display any images on the screen but just generates image files for animation.

Processing code examples.

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



/**
 * The Honey Roll.
 * make wave shape and rotate with the another wave amplitude as an angle.
 * just make image files in frames directory.
 * it not dosplay any images on screen.
 * 
 * @author @deconbatch
 * @version 0.1
 * Processing 3.2.1
 * 2019.05.05
 */

void setup() {
  size(720, 720);
  colorMode(HSB, 360, 100, 100, 100);
  smooth();
  noStroke();
  noLoop();
}

void draw() {

  float hueBase = random(360.0);
  float phaseA  = random(-0.5, 0.5);
  float phaseB  = random(-0.5, 0.5);

  translate(width * 0.5, height * 0.5);

  // make three pattern animation files
  drawShape(1, hueBase, phaseA, phaseB);
  rotate(HALF_PI);
  drawShape(2, hueBase + 60.0, -phaseA, phaseB);
  rotate(HALF_PI);
  drawShape(3, hueBase + 120.0, phaseA, -phaseB);

  exit ();

}

/**
 * drawShape : 
 * @param  _shpCnt   any         : shape count. into the part of image file name.
 * @param  _hueBase  0.0 - 360.0 : base color value.
 * @param  _phaseA, _phaseB  any : phase value of the fomula to calculate the base wave shape.
 */
private void drawShape(int _shpCnt, float _hueBase, float _phaseA, float _phaseB) {

  int frmCntMax = 24;
  for (int frmCnt = 0; frmCnt < frmCntMax; ++frmCnt) {

    float frmRatio  = map(frmCnt, 0, frmCntMax, 0.0, 1.0);
    float easeRatio = easeInOutCubic(frmRatio);
    float rotation  = 0.0;

    blendMode(BLEND);
    background(0.0, 0.0, 100.0, 100.0);
    fill(_hueBase, 5, 90, 50);
    rect(-width * 0.5, -height * 0.5, width, height * 0.5);
    rect(-width * 0.5, -height * 0.5, width * 0.5, height);
    fill(_hueBase, 10, 90, 50);
    rect(-width * 0.5, 0.0, width, height * 0.5);

    blendMode(DIFFERENCE);
    fill(_hueBase, 80, 30.0, 100.0);
    beginShape();

    for (float idxX = 0; idxX <= width; ++idxX) {

      float xRatio = map(idxX, 0, width, 0.0, 1.0);
      float yRatio = sin(cos(xRatio * PI) * TWO_PI);

      float coordX = map(idxX, 0, width, -width * 0.5, width * 0.5);
      float coordY = height * 0.2 * customNoise((_phaseA + xRatio) * TWO_PI, (_phaseB + xRatio) * TWO_PI);

      rotation += TWO_PI * yRatio * easeRatio * 0.01;
      float pointX = coordX * cos(rotation) - coordY * sin(rotation);
      float pointY = coordX * sin(rotation) + coordY * cos(rotation);

      curveVertex(pointX, pointY);
      
    }

    endShape();
    saveFrame("frames/" + String.format("%02d", _shpCnt)  + String.format("%02d", frmCnt) + ".png");

  }

  // make stop motion images
  for (int frmCnt = frmCntMax; frmCnt < frmCntMax + 24; ++frmCnt) {
    saveFrame("frames/" + String.format("%02d", _shpCnt)  + String.format("%02d", frmCnt) + ".png");
  }

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

/**
 * easeInOutCubic easing function.
 * @param  _t    0.0 - 1.0 : linear value.
 * @return float 0.0 - 1.0 : eased value.
 */
private float easeInOutCubic(float _t) {
  _t *= 2.0;
  if (_t < 1.0) {
    return pow(_t, 3) / 2.0;
  }
  _t -= 2.0;
  return (pow(_t, 3) + 2.0) / 2.0;
}

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