Yet Another Brick in the Wall.

A generative art that shows some crayon handwriting feelings.

A picture was drawn with many blicks.

A creative coding example made with Processing.

Yet another product with 'In The Glass'.
It draws many blicks (rectangles and circles) over another by gradually shifting.
It gives me some crayon handwriting feelings. And I love it.

Processing code example.

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.


// Yet Another Brick in the Wall.
// Processing 3.2.1
// @deconbatch
// 2018.05.12
// 2018.05.30 refactored 

void setup() {

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

}

void draw() {

  float baseHue   = random(360);

  background(baseHue, 40, 90, 100);
  translate(width / 2, height / 2);

  drawBricks(baseHue);
  casing(baseHue);

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

}

void drawBricks(float baseHue) {

 // magic numbers
  float decrementMin = 0.980;
  float decrementMax = 0.998;
    
  int   surfaceCount = 10;
  float decrement    = random(decrementMin, decrementMax);
  int   numberX      = floor(map(decrement, decrementMin, decrementMax, 16, 20));
  int   numberY      = numberX;

  float baseSizeX    = width / 2.0;
  float baseSizeY    = height / 2.0;
  float distanceMax  = sqrt(baseSizeX * baseSizeX + baseSizeY * baseSizeY);

  int   baseSeed     = floor(random(100.0));

  for (int surface = surfaceCount; surface > 0; --surface) {

    noiseSeed(baseSeed + surface);   // use another seed in each surface
    
    // surface size
    baseSizeX   *= decrement;
    baseSizeY   *= decrement;
    float divX   = baseSizeX / numberX;
    float divY   = baseSizeY / numberY;

    float surfaceHue = 60.0 * surface / surfaceCount;
    float spacing    = (divX + divY) / 2.0;

    // draw brick
    for (float x = -baseSizeX; x <= baseSizeX; x += divX) {
      for (float y = -baseSizeY; y <= baseSizeY; y += divY) {
        
        float distance  = sqrt(x*x+y*y) + 1;

        pushMatrix();
        translate(x, y);

        noFill();
        strokeWeight(4);
        stroke(
               (360 + baseHue + surfaceHue + map(random(1.0), 0, 1, -30, 30)) % 360,
               random(40.0, 60.0),
               random(90.0, 100.0),
               100
               );
        rect(0, 0, spacing * decrement, spacing * decrement);

        noStroke();
        fill(
             (360 + baseHue + surfaceHue + map(random(1.0), 0, 1, -30, 30)) % 360,
             random(20.0, 80.0),
             random(45.0, 90.0) * (1.0 + distance / distanceMax),
             100
             );
        if (noise(x, y) < 0.3) {
          ellipse(0, 0, spacing * decrement * 0.6, spacing * decrement * 0.6);
        } else {
          rect(0, 0, spacing * decrement * 0.5, spacing * decrement * 0.5);
        }
        
        popMatrix();

      }
    }
  }

}

void casing(float baseHue) {

  fill(0, 0, 100, 0);
  strokeWeight(70);
  stroke((baseHue + 90) % 360, 40, 60, 100);
  rect(0, 0, width, height);
  strokeWeight(50);
  stroke(0, 0, 100, 100);
  rect(0, 0, width, height);

}

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




Code (shameful version)

Guess where is the shameful point?

// Yet Another Brick in the Wall.
// Processing 3.2.1
// 2018.05.12

void setup() {

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

}

void draw() {

  float baseHue   = random(360);

  background(baseHue, 40, 90, 100);
  translate(width / 2, height / 2);

  drawBricks(baseHue);
  casing(baseHue);

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

}

void drawBricks(float baseHue) {

 // magic numbers
  float decrementMin = 0.980;
  float decrementMax = 0.998;
    
  float decrement    = random(decrementMin, decrementMax);
  int   surfaceCount = 10;
  int   numberX      = floor(map(decrement, decrementMin, decrementMax, 16, 20));

  int   numberY   = numberX;
  float baseSizeX = width / 2;
  float baseSizeY = height / 2;
  int   baseSeed  = floor(random(100));

  float distanceMax = sqrt(width * width / 4 + height * height / 4);

  for (int surface = surfaceCount; surface > 0; --surface) {

    noiseSeed(baseSeed + surface);   // use another seed in each surface
    
    // surface size
    baseSizeX *= decrement;
    baseSizeY *= decrement;
    int divX   = floor(baseSizeX / numberX);
    int divY   = floor(baseSizeY / numberY);
    int sizeX  = divX * numberX;
    int sizeY  = divY * numberY;

    float surfaceHue = 60.0 * surface / surfaceCount;
    int   spacing    = floor((divX + divY) / 2.0);

    // draw brick
    for (int x = -sizeX; x <= sizeX; x += divX) {
      for (int y = -sizeY; y <= sizeY; y += divY) {

        float strokeSat = map(noise(x * surface, y), 0, 1, 20, 100);
        float strokeBri = map(noise(x, y * surface), 0, 1, 0, 50);
        float fillSat   = map(noise(x, y * surface), 0, 1, 20, 100);
        float fillBri   = map(noise(x * surface, y), 0, 1, 0, 100);
        float distance  = sqrt(x*x+y*y) + 1;

        pushMatrix();
        translate(x, y);

        noFill();
        strokeWeight(4);
        stroke(
               (360 + baseHue + surfaceHue + map(random(1.0), 0, 1, -30, 30)) % 360,
               random(40.0, 60.0),
               random(90.0, 100.0),
               100
               );
        rect(0, 0, spacing * decrement, spacing * decrement);

        noStroke();
        fill(
             (360 + baseHue + surfaceHue + map(random(1.0), 0, 1, -30, 30)) % 360,
             random(20.0, 80.0),
             random(45.0, 90.0) * (1.0 + distance / distanceMax),
             100
             );
        if (noise(x, y) < 0.3) {
          ellipse(0, 0, spacing * decrement * 0.6, spacing * decrement * 0.6);
        } else {
          rect(0, 0, spacing * decrement * 0.5, spacing * decrement * 0.5);
        }
        
        popMatrix();

      }
    }
  }

}

void casing(float baseHue) {

  fill(0, 0, 100, 0);
  strokeWeight(70);
  stroke((baseHue + 90) % 360, 40, 60, 100);
  rect(0, 0, width, height);
  strokeWeight(50);
  stroke(0, 0, 100, 100);
  rect(0, 0, width, height);

}


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





Yet another bricks image.

A crayon handwriting feeling image.

Many bricks by the simple code.

No comments :

Post a Comment