title

deconbatch's Land of 1000 Creative Codings. example codes of Processing / p5.js, how-to articles, generative art images, and much more!

Summer Day Reflection

Creative coding work that expresses colorful daylight in summer day.

Creative coding work that expresses colorful daylight in summer day.

Trial of an extremely large number of lines.

A creative coding work made with Processing. It draws an image with a large number of color lines.

I tried to draw a 2D shape in repeat lines and columns with two 1D noises, not one 2D noise.

Processing example code.

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

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

// Summer Day Reflection.
// Processing 3.2.1
// 2017.10.14
// @deconbatch

/* ---------------------------------------------------------------------- */
void drawLines() {

  float lineLength = sqrt(height * height + width * width);

  float nsHueStart = random(10.0);
  float nsSatStart = random(10.0);
  float nsRotStart = random(10.0);
  float nsHStart = random(10.0);
  float nsWStart = random(10.0);

  int lineWidthMax = 20;

  for (int lineWidth = 1; lineWidth <= lineWidthMax; ++lineWidth) {

    strokeWeight(0.05 * pow(lineWidth, 2));

    nsHueStart += 0.001;
    float nsHue = nsHueStart;
    float nsSat = nsSatStart;
    float nsH = nsHStart;

    float divH = 1.0;
    float divW = 1.0;

    for (float idxH = 0; idxH < height; idxH += divH) {

      divH = map(noise(nsH), 0.0, 1.0, 80.0, 200.0); // do not use 2D noise
      float nsRot = nsRotStart;
      float nsW = nsWStart;

      for (float idxW = 0; idxW < width; idxW += divW) {

        divW = map(noise(nsW), 0.0, 1.0, 0.0, 5.0); // do not use 2D noise
        float brushHue = map(noise(nsHue), 0.0, 1.0, 0.0, 720.0) % 360.0; // various colors
        float brushSat = map(noise(nsSat), 0.0, 1.0, 20.0, 70.0) / map(lineWidth, 1, lineWidthMax, 1.0, 1.8);
        float brushBri = map(noise(nsSat), 0.0, 1.0, 8.0, 15.0)  / map(lineWidth, 1, lineWidthMax, 1.0, lineWidthMax * 2.8);
        float brushAlp = 100.0;

        float brushSiz = lineLength;
        float brushRot = map(noise(nsRot), 0.0, 1.0, -60.0, 60.0);

        pushMatrix();
        translate(idxW, idxH);
        canvasRotation(brushRot);
        stroke(brushHue, brushSat, brushBri, brushAlp);
        line(-brushSiz, 0.0, brushSiz, 0.0);
        popMatrix();
        
        nsHue += 0.002;
        nsRot += 0.005;
        nsW += 0.01 + noise(nsH) / 10.0; // not to be same shape

      }

      nsSat += 0.05;
      nsH += 0.08;

    }
  }

}

void canvasRotation(float degrees) {

  rotate(radians(degrees));

}

/* ---------------------------------------------------------------------- */
void setup() {

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

}

void draw() {

  background(0.0, 0.0, 0.0, 100.0);
  translate(0.0, 0.0);
  drawLines();

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

}


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




Creative coding work that expresses colorful daylight in summer day.


Post a Comment

0 Comments