Different Points Of View


It must be an accidental coding example.

It's the creative coding work or generative art made with the 'Processing'. 
When I played around with this code, I found that 'blendMode(SCREEN)' and 'pointLight(0, 0, 100, 0, 0, 0)' makes some interesting effect.

I didn't expect it but it came out!
Yes, I used the 'Accidental coding method'. ;-)

'Processing' code examples.

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

Simple version

I don't know why I wrote such a complex code in 2017...


/**
 * Different Points Of View.
 * 
 * @author @deconbatch
 * @version 0.3
 * @license GPL Version 3 http://www.gnu.org/licenses/
 * Processing 3.5.3
 * remake : 2021.05.29
 */

void setup() {
  size(980, 600, P3D);
  colorMode(HSB, 360.0, 100.0, 100.0, 100.0);
  smooth();
  noLoop();

  int   frmMax  = 3;
  int   bCnt    = floor(random(10.0, 50.0));
  float bLen    = max(width, height) * 2.0;
  float baseHue = random(360.0);

  camera(0, 0, bLen * 0.5,
         0, 0, 0,
         0, 1, 0);
  noLights();
  pointLight(0, 0, 100, 0, 0, bLen);
  
  for (int frmCnt = 0; frmCnt < frmMax; frmCnt++) {
    float bSat = random(40.0, 80.0);
    baseHue += 120.0;

    blendMode(BLEND);
    background(0.0, 0.0, 0.0, 100.0);

    blendMode(SCREEN);
    for (int i = 0; i < bCnt; i++) {
      pushMatrix();
      fill((baseHue + random(180.0)) % 360.0, bSat, 50, 100);
      rotateX(random(-1.0, 1.0) * HALF_PI);
      rotateY(random(-1.0, 1.0) * HALF_PI);
      rotateZ(random(-1.0, 1.0) * HALF_PI);
      box(bLen, bLen, bLen);
      popMatrix();
    }

    saveFrame("frames/" + String.format("%04d", frmCnt + 1) + ".png");
  }

  exit();
}


/*
Copyright (C) 2021- 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/>
*/



Accidental coding version


// Different Points Of View 2 : Accidental coding version
// Processing 3.2.1
// 2017.08.20

import java.util.Random;
Utils ut;
BoxinBox bb;

/* ---------------------------------------------------------------------- */
abstract class FountainElement {

  PShape anElement;
  float elementColor, elementSaturation, elementBright, elementAlpha;
  
  FountainElement() {
    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, float scaleZ) {
    anElement.scale(scaleX, scaleY, scaleZ);
  }

  void rotate(float radX, float radY, float radZ) {
    anElement.rotateX(radX);
    anElement.rotateY(radY);
    anElement.rotateZ(radZ);
  }

  void show() {
    shape(anElement);
  }

}

/* ---------------------------------------------------------------------- */
class BoxinBox extends FountainElement {

  BoxinBox() {
    super();
  }

  PShape pscreateElement() {

    noStroke();
    PShape psDp = createShape(GROUP);

    PShape psCh;
    for (int i = 50; i > 45; --i) {
      
      float len = pow(i, 2);
      float rad = radians(i * ut.gaussdist(20, 6, 3));

      psCh = createShape(BOX, len, len, len);
      psCh.setFill(color(random(0, 360), 60, 80, 100));
      psCh.rotateX(rad);
      psCh.rotateY(rad * ut.gaussdist(1.5, 1.0, 0.5));
      psCh.rotateZ(rad * ut.gaussdist(2.0, 1.0, 0.5));
      psDp.addChild(psCh);

    }

    return psDp;

  }

  void setBgcolor() {
    background(random(0, 360), 100, 5);
  }

  void bigBox() {
    fill(random(0, 360), 100, 20, 100);
    rotateY(radians(random(-30,30)));
    rotateZ(radians(random(-60,60)));
    rotateX(radians(random(-60,60)));
    box(2000,2000,1);
  }

}

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

/* ---------------------------------------------------------------------- */
void setup() {
  size(800, 490, P3D);
  colorMode(HSB, 360, 100, 100, 100);
  smooth();
  background(0, 0, 0);
  blendMode(SCREEN);
  ut = new Utils();  
}

void draw() {

  translate(0, 0, 0);
  camera(0, 0, 1200,
         0, 0, 0,
         0, 1, 0);

  lightFalloff(0.5, 0.0008, 0.0);
  pointLight(0, 0, 100, 0, 0, 0);

  bb = new BoxinBox();
  bb.setBgcolor();

  pushMatrix();
  translate(0, 0, -1500);
  bb.bigBox();
  popMatrix();

  pushMatrix();
  translate(0, 0, 0);
  bb.show();
  popMatrix();

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











Generative art example made with Processing in this article.
Generative art example made with Processing in this article.

Video version 

Creative coding works made with Processing and Kdenlive.
It's just a meaningless row of boxes.

Thanks to nice music
Turandot on Ice in Space by Steve Combs
2017/03/25
http://freemusicarchive.org/music/Steve_Combs/Etaoin_Shrdlu/04_Turandot_on_Ice_in_Space
Turandot on Ice in Space by Steve Combs is licensed under a Attribution License.
For more permissions:
contact artist


クリエイティブ・コモンズ・ライセンス



// Different Points Of View
// Processing 3.2.1
// 2017.05.06

import java.util.Random;
Utils ut;
BoxinBox bb;

/* ---------------------------------------------------------------------- */
abstract class FountainElement {

  PShape anElement;
  float elementColor, elementSaturation, elementBright, elementAlpha;
  
  FountainElement() {
    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, float scaleZ) {
    anElement.scale(scaleX, scaleY, scaleZ);
  }

  void rotate(float radX, float radY, float radZ) {
    anElement.rotateX(radX);
    anElement.rotateY(radY);
    anElement.rotateZ(radZ);
  }

  void show() {
    shape(anElement);
  }

}

/* ---------------------------------------------------------------------- */
class BoxinBox extends FountainElement {

  float bgcolor;
  
  BoxinBox() {
    super();
    bgcolor = 0;
  }

  PShape pscreateElement() {

    noStroke();
    PShape psDp = createShape(GROUP);

    PShape psCh;
    for (int i = 3; i < 12; ++i) {
      float len = pow(i, 3);
      float rad = radians(i * ut.gaussdist(20, 10, 5));
      
      psCh = createShape(BOX, len, len, len);
      psCh.setFill(color(random(0, 360), 50, 90, 100));
      psCh.rotateX(rad);
      psCh.rotateY(rad*1.5);
      psCh.rotateZ(rad*2.0);
      psDp.addChild(psCh);
    }

    return psDp;

  }

  void setBgcolor() {
    bgcolor = random(0, 360);
  }

  float getBgcolor() {
    return bgcolor;
  }

}

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

/* ---------------------------------------------------------------------- */
void setup() {
  size(1280, 720, P3D);
  colorMode(HSB, 360, 100, 100, 100);
  smooth();
  background(0, 0, 0);
  frameRate(1);
  blendMode(LIGHTEST);
  ut = new Utils();  
}

void draw() {

  translate(0, 0, 0);
  camera(0, 0, 800,
         0, 0, 0,
         0, 1, 0);

  pointLight(0, 0, 100, 0, 0, 0);

  if (frameCount % 4 == 1) {
    bb = new BoxinBox();
    bb.setBgcolor();
  }
  background(bb.getBgcolor(), 100, 10);
  pushMatrix();
  translate(0, 0, 0);
  bb.show();
  popMatrix();

  /*
    saveFrame("frames/####.png");
    if (frameCount >= 3000) {
    exit();
    }
  */
}

/*
Copyright (C) 2016 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/>
*/


Next Post Previous Post
No Comment
Add Comment
comment url