Creative coding pictorial flower.


How I made this creative coding artwork.

It's a creative coding artwork made with the 'Processing'.

I played around my other work Don't Count the Waves. And it creates an image like this.

Accidentally, it draws a nice image.

 

Not bad.
But it was an accident. It creates a disappointing one almost every time.

 

Make curve smooth. It seems like a flower.
Not bad!

But I felt something boring.

 

So I gave a change with saturation and alpha by gradation.

Not bad, not bad!
...But it does not seem like a flower, I think.

 

I tried not to use blend(screen).

Ah! This is it! This is my taste!
I adjusted parameters, added a background to finish!

It so slow to draw. You might need a cup of coffee. ;-)







 

The 'Processing' code example.

Please feel free to use this 'Processing' example code under the terms of the GPL.
To see other works based on my code is my pleasure. And my honor.

// Full Bloom.
// Processing 3.2.1
// 2017.11.11

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.setFill(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() {

    PShape psDp = createShape(ELLIPSE, 0.0, 0.0, 1.0, 1.0);
    return psDp;

  }

}

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

void setup() {

  size(1080, 1080);
  colorMode(HSB, 360, 100, 100, 100);
  noStroke();
  smooth(8);
  //  noLoop();
  frameRate(1);

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

}

void draw() {

  translate(width / 2, height / 2);

  float baseColor = map(random(1.0), 0.0, 1.0, 0.0, 360.0);
  drawCanvas(baseColor);
  drawFlower(baseColor);
  /*
    saveFrame("frames/####.png");
    exit();
  */

}

void canvasRotation(float degrees) {

  rotate(radians(degrees));

}

void drawCanvas(float pBaseColor) {

  float baseColor = (pBaseColor + 15.0) % 360.0;
  background(baseColor, 5.0, 80.0, 100.0);

  float noiseSat = random(100.0);
  float noiseBri = random(100.0);
  
  for (float w = -width / 2.0; w < width / 2.0; w += 1.0) {

    canvasRotation((noiseSat - noiseBri) / 10.0);
    
    float fillSat = map(noise(noiseSat), 0.0, 1.0, 0.0, 10.0);
    //    float fillBri = map(noise(noiseBri), 0.0, 1.0, 80.0, 90.0);
    float fillBri = map(noise(noiseBri), 0.0, 1.0, 70.0, 80.0);
    
    fill(baseColor, fillSat, fillBri, 30.0);
    rect(w, -height / 1.5, 80.0, height);

    noiseSat += 0.003;
    noiseBri += 0.001;
    
  }

}

void drawFlower(float pBaseColor) {

  // tweak these values
  int divRotate = 6;
  int cntRotateMax = 60 * 360 * divRotate;
  int cntRepeatMax = 80;
  int cntLinesMax = 16;
  float baseSize = 1.0;
  float baseDrawEnd = 200.0;

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

  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;
    float sinMult = abs(ut.gaussdist(0.0, 1.0, 0.7));
    float cosMult = sinMult * round(ut.gaussdist(0.0, 4.0, 2.0));

    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;

      float sizShape = map(cntRepeat, 0, cntRepeatMax, 1.0, 1.3);
      float satShape = map(cntRepeat, 0, cntRepeatMax, 1.6, 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.2);
        float idxH = 0.0;

        float brushHue = (petalColor + 360 + map(noise(noiseHue), 0.0, 1.0, -45.0, 45)) % 360;
        float brushSat = map(noise(noiseSat), 0.0, 1.0, 0.0, 20.0) * satShape;
        //          float brushSiz = map(noise(noiseBri), 0.0, 1.0, 0.0, 2.0);
        float brushSiz = map(noise(noiseAlp), 0.0, 1.0, 0.0, 2.0) * baseSize;
        float brushBri = map(noise(noiseBri), 0.0, 1.0, 90.0, 100.0);
        float brushAlp = map(noise(noiseAlp), 0.0, 1.0, 10.0, 60.0) * alpShape;

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

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

      canvasRotation(-cntRotateMax);

    }
  }
}

/*
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 <http://www.gnu.org/licenses/>
*/


 

Yet another artworks.




 

Next Post Previous Post
No Comment
Add Comment
comment url