Generative art expressing some fear of the dark.


The dark tunnel with flowers.

It' a generative artwork made with the 'Processing'.

I want to express some fear of the dark. Bright and beautiful flower leads me to the dark. And I feel something in the dark.

I used the code from 'Full Bloom' to draw a flower. And I put it to PImage to draw repeatedly.


The example code of this generative art.

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.







// Down in the Hole.
// Processing 3.2.1
// 2018.06.10
// @deconbatch

void setup() {

  size(960, 960);
  colorMode(HSB, 360, 100, 100, 100);
  imageMode(CENTER);
  smooth();
  noLoop();
  noStroke();

}

void draw() {
  
  translate(width / 2, height / 2);

  float hueBase = (160 + random(240)) % 360;  // avoid yellow and green
  background(hueBase, 100, 10, 100);
  blendMode(BLEND);

  // draw flower and copy
  pushMatrix();
  drawFlower(hueBase);
  popMatrix();
  PImage imgFlower = get(width / 2 - 200, height / 2 - 200, 400, 400); // why?

  // draw tunnel
  background(hueBase, 100, 10, 100);
  blendMode(LIGHTEST);

  int depthMax = 50;  // tunnel depth
  for (int depth = depthMax; depth >= 1; --depth) {

    // deeper : small, narrow layout, deeper color, darker
    float ratio     = map(depth, 1, depthMax, 0.0, 0.9);
    int   flwSize   = floor(width * 0.5 * (1.0 - sqrt(ratio)));
    float flwLayout = width * 0.7 * (1.0 - sqrt(ratio));
    float flwSat    = 1.0 + sqrt(ratio);
    float flwBri    = pow(1.0 - sqrt(ratio), 2);
    
    PImage tmpFlower = imgFlower.copy();
    tmpFlower.resize(flwSize, flwSize);
    repaintFlower(
                  tmpFlower,
                  flwSat,
                  flwBri
                  );
    layFlower(tmpFlower, flwLayout);
    rotate(PI*random(1.0));

  }

  saveFrame("frames/0001.png");
  exit();

}

void repaintFlower(PImage img, float saturationRatio, float brightnessRatio) {
  
  for (int idxW = 0; idxW < img.width; ++idxW) {  
    for (int idxH = 0; idxH < img.height; ++idxH) {
      int   idxPoint = idxH * img.width + idxW;
      color cPoint   = img.pixels[idxPoint];
      float valHue   = hue(cPoint);
      float valSat   = saturation(cPoint) * saturationRatio;
      float valBri   = brightness(cPoint) * brightnessRatio;
      float valAlp   = alpha(cPoint);
      img.pixels[idxPoint] = color(valHue, valSat, valBri, valAlp);
    }
  }

}

void layFlower(PImage flower, float radius) {

  for (float radian = 0; radian < 2.0 * PI; radian += PI / 8.0) {
    if (random(1.0) < 0.8) {
      float imgRadius = map(random(1.0), 0.0, 1.0, radius * 0.9, radius * 1.1);
      image(flower, imgRadius * cos(radian), imgRadius * sin(radian));
    }
  }

}

void drawFlower(float pBaseColor) {

  // tweak these values
  int divRotate     = 5;                    // petal width, bigger : thinner
  int cntRotateMax  = 20 * 360 * divRotate; // draw petals from outside to inside, and how many time and again
  int cntRepeatMax  = 30;                   // how soft petal, bigger : soft petal
  int cntLinesMax   = 24;                   // how many different flower set count
  float baseSize    = 3.0;                  // brush size
  float baseDrawEnd = 100.0;                // flower size

  float baseColor     = pBaseColor;
  float noiseHueStart = random(100.0);
  float noiseOrbStart = random(100.0);

  // center of flower
  fill(baseColor, 10, 80, 100);
  ellipse(0, 0, 200, 200);

  // draw petals
  for (int cntLines = 0; cntLines < cntLinesMax; ++cntLines) {

    canvasRotation(180.0 * cntLines / cntLinesMax);

    float noiseSatStart = random(100.0);
    float noiseBriStart = random(100.0);
    float noiseAlpStart = random(100.0);

    float petalColor = baseColor + 30 * cntLines / cntLinesMax;

    for (int cntRepeat = 0; cntRepeat < cntRepeatMax; ++cntRepeat) {

      canvasRotation(4.0 / cntRepeatMax);

      float noiseHue    = noiseHueStart;
      float noiseSat    = noiseSatStart;
      float noiseBri    = noiseBriStart;
      float noiseAlp    = noiseAlpStart;
      float noiseOrb    = noiseOrbStart;
      float sumRotation = 0.0;

      float sizShape = map(cntRepeat, 0, cntRepeatMax, 0.9, 1.3);
      float satShape = map(cntRepeat, 0, cntRepeatMax, 1.4, 0.6);
      float alpShape = map(cntRepeat, 0, cntRepeatMax, 0.1, 1.0);

      for (int cntRotate = 0; cntRotate < cntRotateMax; ++cntRotate) {

        float rotation = 0.2 / divRotate;
        canvasRotation(rotation);
        sumRotation += rotation * map(noise(noiseOrb), 0.0, 1.0, -1.0, 1.0);

        float idxW = baseDrawEnd * abs(sin(radians(sumRotation)) + cos(radians(sumRotation)));
        idxW += map(noise(noiseSat), 0.0, 1.0, -5.0, 60.0);
        idxW *= map(noise(noiseAlp), 0.0, 1.0, 0.6, 1.0);
        float idxH = 0.0;

        float brushHue = (petalColor + 360 + map(noise(noiseHue), 0.0, 1.0, -30.0, 30.0)) % 360;
        float brushSat = map(noise(noiseSat), 0.0, 1.0, 0.0, 30.0) * satShape;
        float brushSiz = map(noise(noiseAlp), 0.0, 1.0, 0.0, 2.0) * baseSize;
        float brushBri = map(noise(noiseBri), 0.0, 1.0, 80.0, 120.0);
        float brushAlp = map(noise(noiseAlp), 0.0, 1.0, 50.0, 100.0) * alpShape;

        noiseHue += 0.001;
        noiseSat += 0.003;
        noiseBri += 0.004;
        noiseAlp += 0.001;
        noiseOrb += 0.008;

        pushMatrix();
        translate(idxW * sizShape, idxH * sizShape);
        fill(brushHue, brushSat, brushBri, brushAlp);
        ellipse(0.0, 0.0, brushSiz, brushSiz);
        popMatrix();
        
      }

      canvasRotation(-cntRotateMax);

    }
  }

}

void canvasRotation(float degrees) {
  rotate(radians(degrees));
}

/*
Copyright (C) 2018- 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 <http://www.gnu.org/licenses/>
*/



Next Post Previous Post
No Comment
Add Comment
comment url