The digital art of the random walking in a linear path
Description of this digital art.
It's a creative coding digital art made with the 'Processing'.
I was interested in Random Walk. I tried to make some tendency to move in a linear path, not a completely random move.
This code does not display any images on the screen but generates image files in frames directory.
The 'Processing' code example.
Please feel free to use this code under the terms of the GPL. To see other works based on my code is my pleasure. And my honor.
// Dreaming While You Sleep.
// @author @deconbatch
// @version 0.2
// Processing 3.2.1
// 2018.10.14
void setup() {
size(980, 980);
colorMode(HSB, 360, 100, 100, 100);
smooth();
noStroke();
}
void draw() {
int walkerNoMax = 450;
float[][] initWalker = new float[3][walkerNoMax];
float baseHue = random(360.0);
float tuneRadian = random(0.2, 1.2);
float radius = 0.0;
float radian = 0.0;
for (int walkerNo = 0; walkerNo < walkerNoMax; ++walkerNo) {
radius += walkerNo * 3.0 / walkerNoMax;
radian += TWO_PI * tuneRadian * (1.0 + noise(walkerNo * 0.05)) / (radius + 1.0);
initWalker[0][walkerNo] = radius * cos(radian);
initWalker[1][walkerNo] = radius * sin(radian);
initWalker[2][walkerNo] = radian;
}
int distanceMax = floor(random(100.0, 800.0));
float tuneRotation = 0.0002;
float tuneSizeOut = random(0.0, 12.0);
float tuneSizeIn = 0.0;
if (tuneSizeOut < 6.0) {
tuneSizeIn = random(6.0, 12.0);
}
blendMode(SUBTRACT);
background((baseHue + 150.0) % 360.0, 5.0, 90.0, 100.0);
translate(width / 2.0, height / 2.0);
pushMatrix();
rotate(random(TWO_PI));
// background whirl
randomWalk(
initWalker,
walkerNoMax,
distanceMax,
tuneRotation * 20.0,
tuneSizeIn * 0.5,
tuneSizeOut * 0.5,
baseHue
);
// front whirl
randomWalk(
initWalker,
walkerNoMax,
distanceMax,
tuneRotation,
tuneSizeIn,
tuneSizeOut,
baseHue
);
popMatrix();
casing(baseHue);
saveFrame("frames/####.png");
if (frameCount >= 3) {
exit();
}
}
private void randomWalk(
float[][] initWalker,
int walkerNoMax,
int distanceMax,
float tuneRotation,
float tuneSizeIn,
float tuneSizeOut,
float baseHue
) {
// deep copy
float[][] walker = new float[initWalker.length][initWalker[0].length];
for (int walkerNo = 0; walkerNo < initWalker[0].length; ++walkerNo) {
walker[0][walkerNo] = initWalker[0][walkerNo];
walker[1][walkerNo] = initWalker[1][walkerNo];
walker[2][walkerNo] = initWalker[2][walkerNo];
}
for (int distance = 0; distance < distanceMax; ++distance) {
float distanceRatio = map(distance, 0, distanceMax, 0.0, 1.0);
float baseSize = map(distanceRatio, 0.0, 1.0, tuneSizeIn, tuneSizeOut);
rotate(-PI * tuneRotation * distanceRatio);
for (int walkerNo = 0; walkerNo < walkerNoMax; ++walkerNo) {
float walkerRatio = map(walkerNo, 0, walkerNoMax, 0.0, 1.0);
float walkerSize = baseSize * (0.1 + walkerRatio);
// random walk
float moveX = walkerRatio * (distanceRatio * (cos(walker[2][walkerNo]) + random(-walkerSize, walkerSize)));
float moveY = walkerRatio * (distanceRatio * (sin(walker[2][walkerNo]) + random(-walkerSize, walkerSize)));
if ((distance + walkerNo) % 2 == 0) {
walker[0][walkerNo] += moveX;
} else {
walker[1][walkerNo] += moveY;
}
fill(
(baseHue + walkerRatio * 60.0) % 360.0,
20.0 + walkerRatio * 20.0 - distanceRatio * 10.0,
walkerRatio + distanceRatio * 6.0,
100.0
);
ellipse(
walker[0][walkerNo],
walker[1][walkerNo],
walkerSize,
walkerSize
);
}
}
}
private void casing(float baseHue) {
blendMode(BLEND);
rectMode(CENTER);
fill(0.0, 0.0, 0.0, 0.0);
strokeWeight(36.0);
stroke((baseHue + 180.0) % 360.0, 80.0, 20.0, 100.0);
rect(0.0, 0.0, width, height);
strokeWeight(30.0);
stroke(0.0, 0.0, 90.0, 100.0);
rect(0.0, 0.0, width, height);
noStroke();
}
/*
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 <http://www.gnu.org/licenses/>
*/

