Devil's Haircut.

An impressive generative artwork with creative coding.
An impressive generative artwork with creative coding.

Description of this generative artwork.

Generative artwork made with Processing.

This is yet another implementation of Vector Field written by GenerateMe.
Drawing vector field
https://generateme.wordpress.com/2016/04/24/drawing-vector-field/
It was so impressive when I drew vector fields symmetrically.
I added some randomness to distort the symmetrically shape a little.

And this code creates three different looks images controlled by variable imgCnt.


Processing code example.

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

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



/**
 * Devil's Haircut.
 * draw 3 custom noise vector field images each different color.
 * reference : https://generateme.wordpress.com/2016/04/24/drawing-vector-field/
 * 
 * @author @deconbatch
 * @version 0.1
 * Processing 3.2.1
 * 2019.03.01
 */

void setup() {

  size(980, 980);
  colorMode(HSB, 360, 100, 100, 100);
  smooth();
  noStroke();
  noLoop();

}

void draw() {
  
  int   plotCntMax = 750;
  float plotDiv    = 0.0005;
  float baseHue    = random(360.0);

  for (int imgCnt = 1; imgCnt <= 3; ++imgCnt) {

    // shape parameters
    float paramA   = random(1.0, 1.5);
    float paramB   = random(3.5, 4.5);
    float plotMult = random(3.0, 6.0);

    float initDiv  = random(0.015, 0.025);
    float baseSiz  = initDiv * initDiv * 5000.0;
    float baseBri  = (1.7 - initDiv * initDiv * 1000) * 100;

    baseHue += 120.0; // 120 hue difference each image
    background(baseHue, 100.0, 10.0, 100);
    blendMode(SCREEN);

    pushMatrix();
    translate(width * 0.5, height * 0.5);
    rotate(HALF_PI * 0.5);
    translate(-width * 0.5 - 40.0, -height * 0.5 - 40.0);

    // draw vector field
    for (float xInit = 0.18; xInit <= 0.82; xInit += initDiv) {
      for (float yInit = 0.18; yInit <= 0.82; yInit += initDiv) {
        // distort a little
        float xPoint = xInit + map(random(1.0), 0.0, 1.0, -0.1, 0.1) * initDiv;
        float yPoint = yInit + map(random(1.0), 0.0, 1.0, -0.1, 0.1) * initDiv;
        for (int plotCnt = 0; plotCnt < plotCntMax; ++plotCnt) {

          float plotRatio = map(plotCnt, 0, plotCntMax, 0.0, 1.0);
          float eHue      = baseHue + plotRatio * 60.0 + floor(((xInit * yInit) * 10000.0) % 4.0) * 15.0;;
          float eSat      = map(sin(PI * plotRatio), 0.0, 1.0, 70.0, 40.0);
          float eBri      = baseBri * (1.0 - sin(PI * plotRatio));
          float eSiz      = baseSiz * sin(PI * plotRatio);

          float xPrev = xPoint;
          float yPrev = yPoint;
          xPoint += plotDiv * pow(cos(TWO_PI * customNoise(xPrev * paramA, yPrev * paramB) * plotMult), imgCnt);
          yPoint += plotDiv * pow(cos(TWO_PI * customNoise(yPrev * paramA, xPrev * paramB) * plotMult), imgCnt);

          fill(eHue % 360.0, eSat, eBri, 100.0);
          ellipse(xPoint * width, yPoint * height, eSiz, eSiz);

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

  }

  exit();

}

/**
 * casing : draw fancy casing
 */
private void casing() {
  blendMode(BLEND);
  fill(0.0, 0.0, 0.0, 0.0);
  strokeWeight(60.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();
}

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

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





Example images.

Generative art that seems devil's hair.

Generative art that seems devil's hair.


No comments :

Post a Comment