Pattern Recognition.

A simple pattern with Fibonacci number.
A simple pattern with Fibonacci number.

Yet another pattern with Fibonacci number.

Creative coding work made with Processing on Java programming language.

It creates simple pattern with Fibonacci number.

Processing example code.

Please feel free to use it, if you like it.
To see other works based on my code is my pleasure. And my honor.


// Pattern Recognition.
// @author @deconbatch
// @version 01
// Processing 3.2.1
// 2018.09.12

void setup() {
  size(980, 980);
  colorMode(HSB, 360, 100, 100, 100);
  blendMode(BLEND);
  rectMode(CENTER);
  smooth();
  noLoop();
}

void draw() {

  int   drawCntMax = 8;
  float caseWidth  = 20.0;
  float divRate    = random(0.2, 1.0);
  float hueBase    = random(360.0);
  
  background(hueBase, 5.0, 90.0, 100.0);
  translate(width / 2.0, height / 2.0);
  strokeWeight(divRate);
  stroke(hueBase, 5.0, 90.0, 100.0);

  // Fibonacci number
  float divNext = 1597 * divRate;
  float divPrev = 987 * divRate;

  float canvasW = width * 0.5 - caseWidth;
  float canvasH = height * 0.5 - caseWidth;

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

    float div = divNext - divPrev;
    float hueApply = (hueBase + map(drawCnt, 1, drawCntMax, 0.0, 90.0)) % 360.0;
    float satApply = map(drawCnt, 1, drawCntMax, 10.0, 40.0);
    float briApply = map(drawCnt, 1, drawCntMax, 80.0, 30.0);
    
    for (float x = 0.0; x < canvasW; x += divNext) {
      for (float y = 0.0; y < canvasH; y += divNext) {
        fill(hueApply, satApply, briApply, (divRate + 1.0) * 50.0);
        ellipse( x,  y, div, div);
        ellipse(-x,  y, div, div);
        ellipse( x, -y, div, div);
        ellipse(-x, -y, div, div);
      }
    }

    divNext = divPrev;
    divPrev = div;

  }

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

void casing(float caseWidth) {

  fill(0.0, 0.0, 100.0, 0.0);
  strokeWeight(caseWidth * 2.0);
  stroke(0.0, 0.0, 100.0, 100.0);
  rect(0.0, 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 
*/





No comments :

Post a Comment