/*Jahnae Miller

Oct. 2017

Inspired by 197A by Manfred Mohr

*/

int offset = 25;

int maxFromCentre = 25;

int minFromCentre = 5;

int no_of_lines = 8;

int minInnerLineLength = 10;

int maxInnerLineLength = 20;

void setup()

{

int pass = 0;

size(500, 500);

background(255);

pass = drawHorizontalLines();

drawShapesVertically(pass);

drawVerticalLines();

}

int drawHorizontalLines()

{

int step = 0;

step = width/no_of_lines;

int y_pos = step;

int w_ypos = step + 1;

for (int x = 0; x < no_of_lines - 1; x += 1)

{

stroke(20, 70);

line(offset, y_pos, height - offset, y_pos);

y_pos += step;

stroke(230);

line(offset, w_ypos, height - offset, w_ypos);

w_ypos += step;

}

return step;

}

void drawVerticalLines()

{

int step = 0;

step = width/no_of_lines;

int x_pos = step;

int w_xpos = step + 1;

for (int x = 0; x < no_of_lines - 1; x += 1)

{

stroke(20, 70);

line(x_pos, offset, x_pos, height - offset);

x_pos += step;

stroke(230);

line(w_xpos, offset, w_xpos, height - offset);

w_xpos += step;

}

}

void drawShapesHorizontally(int step, int y)

{

int x = step;

for (int i = 0; i < no_of_lines - 1; i++)

{

float x1 = x - random(minFromCentre, maxFromCentre);

float y1 = y - random(minFromCentre, maxFromCentre);

float x2 = x + random(minFromCentre, maxFromCentre);

float y2 = y - random(minFromCentre, maxFromCentre);

float x3 = x + random(minFromCentre, maxFromCentre);

float y3 = y + random(minFromCentre, maxFromCentre);

float x4 = x - random(minFromCentre, maxFromCentre);

float y4 = y + random(minFromCentre, maxFromCentre);

stroke(30, 150);

quad(x1, y1, x2, y2, x3, y3, x4, y4);

drawInnerLines(x1, y1, x2, y2, x3, y3, x4, y4);

stroke(30, 150);

x += step;

}

}

void drawShapesVertically(int step)

{

int y = step;

for (int i = 0; i < no_of_lines - 1; i++)

{

drawShapesHorizontally(step, y);

y += step;

}

}

void drawInnerLines(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)

{

stroke(0);

if (random(0, 100) > 75)

{

drawDiagonals(x1, y1, x2, y2, x3, y3, x4, y4);

}

else

{

drawRandomInternalLines(x1, y1, x2, y2, x3, y3, x4, y4);

}

}

void drawDiagonals(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)

{

line(x1, y1, x3, y3);

line(x2, y2, x4, y4);

}

void drawRandomInternalLines(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)

{

line(x1, y1, x1 + random(minInnerLineLength, maxInnerLineLength), y1 + random(minInnerLineLength, maxInnerLineLength));

line(x2, y2, x2 - random(minInnerLineLength, maxInnerLineLength), y2 + random(minInnerLineLength, maxInnerLineLength));

line(x3, y3, x3 - random(minInnerLineLength, maxInnerLineLength), y3 - random(minInnerLineLength, maxInnerLineLength));

line(x4, y4, x4 + random(minInnerLineLength, maxInnerLineLength), y4 - random(minInnerLineLength, maxInnerLineLength));

}