I Saw The Light.

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


Description of this work.

I wanted to make something with colors.
I used to use a SAFE color combination like the Dominant tone.

This time, I tried to use 210 degrees differ colors in HSB mode.
Using blendMode(DIFFERENCE) and 30 degrees differ in hue value makes 210 degrees differ colors in the result.

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

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.



/**
 * I Saw The Light.
 * 
 * I wanted to make something with colors.
 * 
 * @author @deconbatch
 * @version 0.1
 * Processing 3.2.1
 * 2019.06.09
 */

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

void draw() {

  // color variation within 60.0 degrees
  float hueDiv  = 60.0;
  float hueInit = random(hueDiv);

  translate(width * 0.5, height * 0.5);

  // draw three images with differect color
  for (int imgCnt = 1; imgCnt <= 3; imgCnt++) {

    float hueBase = 320 + (hueInit + imgCnt * 20.0) % hueDiv; // choose nice color
    float factorA = random(1.0, 2.0);
    float factorB = random(1.0, 2.0);

    background((hueBase + 180.0) % 360.0, 100.0, 100.0, 100.0);  

    blendMode(DIFFERENCE);
    drawWave(400, factorA, factorB, hueBase);
    blendMode(ADD);
    drawWave(100, factorA, factorB, hueBase + 30.0);
  
    casing();
    saveFrame("frames/" + String.format("%04d", imgCnt) + ".png");

  }
  
  exit ();

}

/**
 * drawWave
 * @param  _lineMax  : number of waves to draw.
 * @param  _factorA, _factorB : wave shape factor.
 * @param  _hueBase  : wave color.
 */
private void drawWave(int _lineMax, float _factorA, float _factorB, float _hueBase) {

    noStroke();
    fill(_hueBase % 360.0, 80, 30.0, 40.0);

    pushMatrix();
    for (int lineCnt = 0; lineCnt < _lineMax; ++lineCnt) {

      float lineRatio = map(lineCnt, 0, _lineMax, 0.0, 1.0);

      rotate(PI * lineRatio);
      beginShape();
      for (int idxX = 0; idxX <= width; ++idxX) {

        float xRatio = map(idxX, 0, width, 0.0, 1.0);

        float coordX = width * 1.3 * (xRatio - 0.5);
        float coordY = height * 0.1 * customNoise((_factorA + xRatio) * TWO_PI, (_factorB + xRatio) * TWO_PI);

        // I can't use rotate() because of vertex()
        float radian = TWO_PI * lineRatio;
        float pointX = coordX * cos(radian) - coordY * sin(radian);
        float pointY = coordX * sin(radian) + coordY * cos(radian);

        vertex(pointX, pointY);

      }
      endShape();
    }
    popMatrix();

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

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

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

br />

No comments :

Post a Comment