Based on: Traveling Through the Square Series by Roger Coqart, 1976
Category: direct
Description:
This sketch is running in the browser.
/* Part of the ReCode Project (http://recodeproject.com) Based on "Traveling Through the Square Series" by Roger Coqart Originally published in "Computer Graphics and Art" v1n3, 1976 Copyright (c) 2015 Ciaron Linstead - OSI/MIT license (http://recodeproject/license). */ /* @pjs pauseOnBlur="true"; */ /* http://recodeproject.com/artwork/v1n3traveling-through-the-square-series */ int prob = 8; // 1 to 11 void setup() { size(1200, 800); background(255); int hcells=width/100; // number of cells in x direction int vcells=height/100; // number of cells in y direction ArrayList<Line> lines = new ArrayList<Line>(); for (int y=0; y<=height; y+=height/vcells) { for (int x=0; x<=width; x+=width/hcells) { /* HANDLE IMAGE EDGES */ // top and bottom edges: if (y==0 || y>(height-height/vcells)) { lines.add(new Line(x, y, x+width/hcells, y)); } // left and right edges: if (x==0 || x>(width-width/hcells)) { lines.add(new Line(x, y, x, y+height/vcells)); } /* END HANDLE IMAGE EDGES */ // what we want is a 1 in 4 chance of each of top, left, left-diag, right-diag: if ((random(1,11)) <= prob) lines.add(new Line(x,y,x+width/hcells, y+height/vcells)); if ((random(1,11)) <= prob) lines.add(new Line(x+width/hcells, y, x, y+height/vcells)); if ((random(1,11)) <= prob) lines.add(new Line(x, y, x, y+height/vcells)); if ((random(1,11)) <= prob) lines.add(new Line(x, y, x+width/hcells, y)); } } for (Line line : lines) { line.drawOuter(); } for (Line line : lines) { line.drawInner(); } } class Line { float x1, y1, x2, y2; int outerStroke=0; int innerStroke=255; int outerStrokeWeight=25; int innerStrokeWeight=8; Line(float x1_, float y1_, float x2_, float y2_) { x1=x1_; x2=x2_; y1=y1_; y2=y2_; } void drawOuter() { stroke(outerStroke); strokeWeight(outerStrokeWeight); line(x1, y1, x2, y2); } void drawInner() { stroke(innerStroke); strokeWeight(innerStrokeWeight); line(x1, y1, x2, y2); } }