How to make a vortex with rectangles?

A vortex image made with many rectangles.

Trying to enhance the contrast with tuning brightness.

It's a generative art made with the 'Processing'.

I featured the Full Bloom background and made that as this original artwork. This Processing code creates a vortex with simple rectangles.

I tried to enhance contrast with this code.

  float fillBri = constrain(map(noise(noiseBri), 0.0, 1.0, -_baseBri * 0.5, _baseBri), 0.0, 100.0);

 







The 'Processing' example code.

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. :-)

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

/**
 * Rock Candy.
 * 
 * @author @deconbatch
 * @version 0.2
 * Processing 3.2.1
 * draw circle with rect() in multiple blend mode.
 * ver 0.1 : created 2017.11.13
 * ver 0.2 : updated 2019.08.30
 *           contrast enhancement.
 *           add casing.
 *           refactoring done.
 */

void setup() {
  size(980, 980);
  colorMode(HSB, 360.0, 100.0, 100.0, 100.0);
  noStroke();
  smooth();
  noLoop();
}

void draw() {

  float baseHue = random(360.0);

  background(0.0, 0.0, 100.0, 100.0);
  translate(width * 0.5, height * 0.5);

  blendMode(BLEND);
  drawVortex(baseHue, 200.0, 20.0);
  blendMode(ADD);
  drawVortex(baseHue + 60.0, 10.0, 0.5);
  blendMode(BLEND);
  rectMode(CENTER);
  casing();

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

}

/**
 * drawVortex easing function.
 * @param  _baseHue    : hue value of rectangle.
 * @param  _baseBri    : brightness value of rectangle.
 * @param  _baseWidth  : base width of rectangle.
 */
void drawVortex(float _baseHue, float _baseBri, float _baseWidth) {

  int   drawMax = 3;
  float rectY   = random(height);
  float rectH   = height;
  
  float noiseSat = random(100.0);
  float noiseBri = random(100.0);
  float noiseRot = random(100.0);

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

    float rectW   = map(drawCnt, 1, drawMax, 1.0, _baseWidth);
    float fillHue = _baseHue + map(drawCnt, 1, drawMax, 0.0, 90.0);
    float fillAlp = map(drawCnt, 1, drawMax, 60.0, 5.0);

    pushMatrix();
    for (float rectX = -width * 0.5; rectX < width * 0.5; rectX += 0.05) {

      rotate(PI * noise(noiseRot) * 0.002);

      float fillSat = map(noise(noiseSat), 0.0, 1.0, 80.0, 100.0);
      float fillBri = constrain(map(noise(noiseBri), 0.0, 1.0, -_baseBri * 0.5, _baseBri), 0.0, 100.0); // amplify contrast
      fill(fillHue % 360.0, fillSat, fillBri, fillAlp);
      rect(rectX, -rectY, rectW, rectH);

      noiseSat += 0.002;
      noiseBri += 0.003;
      noiseRot += 0.005;
    
    }
    popMatrix();

  }
}

/**
 * casing : draw fancy casing
 */
private void casing() {
  fill(0.0, 0.0, 0.0, 0.0);
  strokeWeight(58.0);
  stroke(0.0, 0.0, 0.0, 100.0);
  rect(0.0, 0.0, width, height);
  strokeWeight(50.0);
  stroke(0.0, 0.0, 100.0, 100.0);
  rect(0.0, 0.0, width, height);
  noStroke();
  noFill();
}

/*
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 example image.


A vortex image made with many rectangles.

 

Next Post Previous Post
No Comment
Add Comment
comment url