farcar – Interruptions

Observations:

  • The lines are black
  • The lines have thin strokes
  • The lines are equal lengths
  • The lines are ordered on a grid-like system
  • The lines face arbitrary directions
  • Some areas are patches lacking any lines
  • The canvas is a light grey
  • The canvas is square
  • The lines formed closed shapes
  • There is a small bleed area between the lines and the edge of the canvas

Program:

Process:

In remaking this work, I laid out a grid where lines of equal lengths facing arbitrary directions would be drawn out. To make for the patches the original drawing had, I gave the program a 70% chance of drawing a line at each coordinate. While I felt that I represented this project well, I wanted to do more with it. I felt that the patches were one of the highlights of the piece, and wanted there to be a slight component of interactivity. As a result, I made it such that the location the user clicks on to activate a new piece will generate a gap in that area, and stay there after each successive generation. Not only was the user generating a new piece, but they were helping to make it too.

Code:

//saves the locations of where you clicked
var gapX = []
var gapY = []
 
//draws a stream of lines using two for-loops
function setup(x, y) {
	createCanvas(500, 500);
	background(225);
	var tempX = [];
	var tempY = [];
	var tempW = [];
	var tempH = [];
	//randomly creates areas to place gaps
	var end = random(15);
	for(var h = 0; h < end; h++) {
		append(tempX, random(500));
		append(tempY, random(500));
		append(tempW, random(30));
		append(tempH, random(30));
	}
	append(gapX, x);
	append(gapY, y);
	for(var i = 0; i < width; i+=6) {
		for(var j = 0; j < height; j+=7) {
			//checks for overlap with gaps, and gives it a 70% chance of drawing a line
			var overlap = false;
			var chance = random();
			//checks overlap agains every gap pos
			for(var k = 0; k < gapX.length; k++)
				if(gapX[k]-30 < i && i < gapX[k]+30 && gapY[k]-30 < j && j < gapY[k]+30)
					overlap = true;
			for(var l = 0; l < tempX.length; l++)
				if(tempX[l] - tempW[l] < i && i < tempX[l] + tempW[l] && tempY[l] - tempH[l] < j && j < tempY[l] + tempH[l]) 
					overlap = true; 
			if(!overlap && (chance < 0.7))
				lineByAngle(i, j, random(1/4*PI,3/4*PI), 20);
		}
	}
}
 
//resets upon click
function draw() {
	if(mouseIsPressed)
		setup(mouseX, mouseY);
}
 
//draws line based on an (x,y) origin pair in a radial system
function lineByAngle(x, y, rad, len) {
	line(x,y,x+len*sin(rad),y+len*cos(rad));
}