Hole In My Soul.

It draws interesting orbs around the hole.

It draws circled orbs around the hole with a large number of lines.

About this generative art.

A generative art made with Processing programming code.
It draws circled orbs around the hole with a large number of lines. It derived from Big Bang.

I might not need the PshapeElement class to draw this at all. But I wanted to use an abstract class that I studied recently.
The PshapeElement is a brush of this code. I use line() as a brush this time. Changing brush like rect(), ellipse(), etc. will make different looks.

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.


// Hole In My Soul
// Processing 3.2.1
// 2017.08.19

import java.util.Random;

/* ---------------------------------------------------------------------- */
class Utils {

  Random obj_random;

  Utils() {
    obj_random = new Random();
  }

  float gaussdist(float pmean, float plimit, float pdevi) {
    /**
       Gaussian distribution
       1.parameters.
       pmean  : mean value
       plimit : max value of abs(deviation)
       ex. plimit >= 0
       pmean = 0.5, plimit = 0.5 -> return value = from 0.0 to 1.0
       pdevi  : standard deviation value
       ex. good value? -> pdevi = plimit / 2
       2.return.
       gaussian distribution
    **/

    if (plimit == 0) {
      return pmean;
    }

    float gauss = (float) obj_random.nextGaussian() * pdevi;
    // not good idea
    if (abs(gauss) > plimit) {
      gauss = pow(plimit, 2) / gauss;
    }

    return pmean + gauss;
    
  }
}

/* ---------------------------------------------------------------------- */
abstract class PshapeElement {

  PShape anElement;
  float elementColor, elementSaturation, elementBright, elementAlpha;
  
  PshapeElement() {
    anElement = pscreateElement();
    elementColor = 0;
    elementSaturation = 0;
    elementBright = 0;
    elementAlpha = 0;
  }

  abstract PShape pscreateElement();

  void setElementFill(float pcolor, float psaturation, float pbright, float palpha) {
    elementColor = pcolor;
    elementSaturation = psaturation;
    elementBright = pbright;
    elementAlpha = palpha;
    resetColor();
  }

  void resetColor() {
    anElement.setStroke(color(elementColor, elementSaturation, elementBright, elementAlpha));
  }

  void changeColor(float scolor) {
    elementColor = scolor;
    resetColor();
  }

  void changeBright(float sbright) {
    elementBright = sbright;
    resetColor();
  }

  void resetSize() {
    anElement.resetMatrix();
  }

  void changeSize(float scaleX, float scaleY) {
    anElement.scale(scaleX, scaleY);
  }

  void rotate(float radX) {
    anElement.rotate(radX);
  }

  void show() {
    shape(anElement);
  }

}

/* ---------------------------------------------------------------------- */
class Brush extends PshapeElement {
  
  Brush() {
    super();
  }

  PShape pscreateElement() {

    noFill();
    strokeWeight(0.000001);
    PShape psDp = createShape(LINE, 0.0, 0.0, 0.0, 0.1);
    return psDp;

  }

}

/* ---------------------------------------------------------------------- */
Utils ut;
PshapeElement brush;

void setup() {
  size(900, 900);
  colorMode(HSB, 360, 100, 100, 100);
  blendMode(SCREEN);
  smooth(8);
  noLoop();
  //  frameRate(1);

  ut = new Utils();  
  brush = new Brush();

}

void draw() {

  background(0, 0, 0);
  translate(width / 2, height / 2);

  drawEye();

  saveFrame("frames/####.png");
  exit();
  
}

void canvasRotation(float degrees, float fluctuation) {

  rotate(radians(degrees));
  translate(random(fluctuation), random(fluctuation));

}

void drawEye() {

  int divCntMin = 1;
  int divCntMax = 8;
  int drawCntMax = 360;
  float idxDiv = 3;

  float baseColor = random(360.0);
  float drawStart = abs(ut.gaussdist(10.0, 3.0, 2.0));
  float baseDrawEnd = drawStart + abs(ut.gaussdist(80.0, 10.0, 5.0));

  float noiseHueStart = random(100.0);
  float noiseSatStart = random(100.0);
  float noiseBriStart = random(100.0);
  float noiseRotStart = random(100.0);
 
  float sinMult = abs(ut.gaussdist(0.0, 1.0, 0.7));
  float cosMult = sinMult * round(ut.gaussdist(0.0, 4.0, 2.0));

  float noiseHue = noiseHueStart;

  for (int divCnt = divCntMin; divCnt <= divCntMax; ++divCnt) {

    float noiseRot = noiseRotStart;
    float sumRotation = 0;

    // Shift whole shape
    canvasRotation(ut.gaussdist(2.0, 1.0, 0.5), 0.0);

    for (int drawCnt = 0; drawCnt < drawCntMax; ++drawCnt) {

      float rotation = map(noise(noiseRot), 0.0, 1.0, 0.5, 1.5);
      canvasRotation(rotation, rotation / 2.0);
      noiseRot += 0.05;
      sumRotation += rotation;
          
      float brushHue = (baseColor + 360 + map(noise(noiseHue), 0.0, 1.0, -60.0, 60)) % 360;
      noiseHue += 0.02;

      float noiseSat = noiseSatStart;
      float noiseBri = noiseBriStart;
      float drawEnd = baseDrawEnd * abs(sin(radians((sumRotation) * sinMult)) + cos(radians((sumRotation) * cosMult)));

      for (float idxW = drawStart; idxW < drawEnd; ++idxW) {
        for (float idxH = drawStart; idxH < drawEnd; ++idxH) {

          float brushSat = map(noise(noiseSat), 0.0, 1.0, 40.0, 100.0);
          float brushSiz = map(noise(noiseBri), 0.0, 1.0, 0.0, 30.0);
          float brushBri = map(noise(noiseBri), 0.0, 1.0, 0.0, 50.0);
          float brushAlp = map(noise(noiseBri), 0.0, 1.0, 0.0, 60.0);
          noiseSat += 0.003;
          noiseBri += 0.001;

          pushMatrix();
          translate(idxW * idxDiv, idxH * idxDiv);
          brush.resetSize();
          brush.changeSize(brushSiz, brushSiz);
          brush.setElementFill(brushHue, brushSat, brushBri, brushAlp);
          brush.show();
          popMatrix();
        
        }
      }
    }

    canvasRotation(-sumRotation, 0.0);

  }
}


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




A generative art that draws circled orbs around the hole with a large number of lines.

A generative art that draws interesting orbs around the hole.


No comments :

Post a Comment