var oscillatingFunction, oscillatingFunctionLength;
var hSegments, vSegments, hSize, vSize, segmentSize, rotation;
createCanvas(screenSize, screenSize);
gB = createGraphics(gBRes, gBRes);
hSegments = 16 + ~~random(16);
vSegments = 16 + ~~random(16);
segmentSize = gBRes * random() * random() * random() * random();
oscillatingFunctionLength = 2 + ~~random(16);
oscillatingFunction = [];
for (var i = 0; i < oscillatingFunctionLength; i += 1) {
oscillatingFunction.push( random( 0, i%2 == 0 ? 1 : -1 ) );
gB.strokeWeight(gBRes * 0.00125);
for (var i = 0; i <= 1; i += hSize) {
for (var j = 0; j <= 1; j += vSize) {
var xPos = map(i, 0, 1, 0 * gB.width, gB.width);
var yPos = map(j, 0, 1, 0 * gB.height, gB.height);
gB.translate(xPos, yPos);
gB.rotate(rotation * PI * 0.5);
var position = ~~map(i * j, 0, 1, 1, oscillatingFunction.length);
var currentOF = oscillatingFunction[position];
var prevOF = oscillatingFunction[position - 1];
var midVal = lerp(currentOF, prevOF, i);
gB.line(-segmentSize, prevOF * segmentSize, segmentSize, midVal * segmentSize);
gB.line(segmentSize, midVal * segmentSize, -segmentSize, currentOF * segmentSize);
translate(width * 0.5, height * 0.5);
image(gB, 0, 0, width * 0.975, height * 0.975);
strokeWeight(screenSize * 0.005);
rect(0, 0, width * 0.975, height * 0.975);
screenSize = min(windowWidth, windowHeight);
function windowResized() {
resizeCanvas(screenSize, screenSize);
function mouseClicked() {