15/02/2020
Porting this to Processing3
void setup() {
size(320, 320);
background(255);
}
void drawLine(int x, int y, int w, int h) {
stroke(0);
if ( random(1) > 0.5)
{
line(x, y, x+w, y+h);
}
else
{
line(x+w, y, x, y+h);
}
}
void drawCanvas(int step){
for (int x = 0; x < width; x += step) {
for (int y = 0; y < height; y += step) {
drawLine(x, y, step, step);
}
}
save(String.format("%d.png", step));
}
void draw() {
int step = 5;
drawCanvas(step);
exit();
}
Changing step
size (clockwise: 4, 8, 16, and 32)
Different color for left-to-right and right-to-left
void drawLine(int x, int y, int w, int h) {
if ( random(1) > 0.5)
{
stroke(255, 0, 255);
line(x, y, x+w, y+h);
}
else
{
stroke(123, 0, 255);
line(x+w, y, x, y+h);
}
}
Changing thresh
void drawLine(int x, int y, int w, int h, float thresh) {
if ( random(1) > thresh)
{
stroke(255, 0, 255);
line(x, y, x+w, y+h);
}
else
{
stroke(123, 0, 255);
line(x+w, y, x, y+h);
}
}
Randomise stroke thickness
void drawLine(int x, int y, int w, int h, float thresh) {
strokeWeight(random(2));
if ( random(1) > thresh)
{
stroke(255, 0, 255);
line(x, y, x+w, y+h);
}
else
{
stroke(123, 0, 255);
line(x+w, y, x, y+h);
}
}
Overlap two iterations
Bonus: bash it!
while [ 1 ]; do printf "\u257"$( shuf -i 1-2 -n 1); done