Signal Fade.

Moving line belt animation that was made with Processing.

Moving line belt animation that was made with Processing.





Description of this creative coding.

A creative coding work made with Processing.

Yet another production with playing around the sine curve.
I found it makes an interesting line belt. I turned these line belts with colors and brightness.

It looks good in blendMode(SCREEN) and blendMode(DIFFERENCE) either.
An example image with blendMode(DIFFERENCE).

Related production.
Listening Wind.

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

Processing code example.

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


// Signal Fade.
// @author @deconbatch
// @version 0.1
// Processing 3.2.1
// 2019.01.10

void setup() {

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

void draw() {

  int   frameCntMax = 24 * 6;
  int   lineCntMax  = 9;
  float baseWidth   = width * 0.2 / lineCntMax;
  float baseHeight  = width * 0.4;
  float baseHue     = random(360);

  translate(width / 2, height / 2);

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

    float frameRatio  = map(frameCnt, 0, frameCntMax, 0.0, 1.0);
    float easingFrame = easeInOutCubic(frameRatio);
    
    blendMode(SCREEN);
    background(baseHue, 100.0, 10.0, 100.0);
      
    for (int lineCnt = 0; lineCnt < lineCntMax; ++lineCnt) {

      // shift start frame of easing with each line
      float easingLine = easePow((frameRatio + lineCnt * 1.0 / lineCntMax) % 1.0);
      
      float lineRadian = lineCnt * TWO_PI / lineCntMax;
      float lineDiv    = constrain(1.0 - sin(lineCnt * PI / (lineCntMax - 1)), 0.0, 1.0);
      float cRadianDiv = PI * (0.0004 + lineDiv * 0.002);
    
      for (float cRadian = 0.0; cRadian < TWO_PI; cRadian += cRadianDiv) {
        
        float cX = sin(cRadian) * baseWidth + (lineCnt - (lineCntMax - 1) / 2.0) * baseWidth * 3.8;
        float cY = sin(cRadian + TWO_PI * easingFrame + lineRadian) * baseHeight;

        float hueBasis = 360.0 + baseHue + sin(PI * easingFrame) * 30.0;
        float hueWave  = TWO_PI * (easingLine * 3.0 + sin(cRadian + TWO_PI * easingFrame));
        float cHue     = (hueBasis + 30.0 * sin(hueWave)) % 360.0;

        float cParam   = constrain((1.0 + sin(cRadian + TWO_PI * easingFrame + HALF_PI + lineRadian)) * 0.5, 0.0, 1.0);
        float cBriFine = map(cParam, 0.0, 1.0, 0.0, 5.0);
        float cBriBold = cBriFine * 0.03 * abs(sin(hueWave) + cos(TWO_PI * cParam * 2.0) + 3.0);
        float cSize    = (cParam + 1.0) * 4.0;

        fill(cHue, 30.0, cBriFine, 100.0);
        rect(cX, cY, cSize, cSize);

        fill(cHue, 40.0, cBriBold, 100.0);
        rect(cX, cY, cSize * 6.0, cSize * 6.0);

        cHue = (hueBasis + 30.0 * cos(hueWave)) % 360.0;
        fill(cHue, 30.0, cBriFine, 100.0);
        rect(cY, cX, cSize, cSize);

        fill(cHue, 40.0, cBriBold, 100.0);
        rect(cY, cX, cSize * 6.0, cSize * 6.0);

      }
    }

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

  }

  exit();

}

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

}

/**
 * easePow easing function.
 * @param  t     0.0 - 1.0 : linear value.
 * @return float 0.0 - 1.0 : eased value.
 */
private float easePow(float t) {

  return t * t;

}

/**
 * casing : draw fancy casing
 * @param  hueBase : casing color.
 */
private void casing(float baseHue) {

  blendMode(BLEND);
  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, 80.0, 100.0);
  rect(0.0, 0.0, width, height);
  noStroke();

}

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