xxxxxxxxxx
476
var options = [
"RED",
"BRIGHTOLIVEGREEN",
"FLUORESCENTORANGE",
"FLUORESCENTPINK",
]
var colors = [];
var c;
var ink1, ink2, ink3, ink4;
function setup() {
pixelDensity(2);
c = createCanvas(windowHeight * .9, windowHeight * .9); // Create SVG Canvas
noLoop();
ink1 = round(random(0,options.length-1));
console.log(options[ink1]);
ink2 = round(random(0,options.length-1));
console.log(options[ink2]);
ink3 = round(random(0,options.length-1));
console.log(options[ink3]);
ink4 = round(random(0,options.length-1));
console.log(options[ink4]);
colors = [
new Riso(options[ink2]),
new Riso(options[ink1]),
new Riso(options[ink3]),
new Riso(options[ink4])];
}
var start, end, side, center;
function draw() {
start = 0;
end = width;
side = end-start;
center = start + (side / 2);
jokagbo(180, 180, start, start, end, end);
colors[2].cutout(colors[0]); //cut out bow
colors[3].cutout(colors[0]);
colors[0].cutout(colors[1]); //cut out bow line
colors[2].cutout(colors[1]);
//colors[3].cutout(colors[1]);
//console.log(colors[0].channelName)
drawRiso();
//exportRiso();
}
function mousePressed() {
ink1 = round(random(0,options.length-1));
console.log(options[ink1]);
ink2 = round(random(0,options.length-1));
console.log(options[ink2]);
ink3 = round(random(0,options.length-1));
console.log(options[ink3]);
ink4 = round(random(0,options.length-1));
console.log(options[ink4]);
colors = [
new Riso(options[ink2]),
new Riso(options[ink1]),
new Riso(options[ink3]),
new Riso(options[ink4])];
clearRiso();
background(255);
jokagbo(180, 180, start, start, end, end);
drawRiso();
}
// recursion happens in here
function jokagbo(stopW, stopH, minX, minY, maxX, maxY) {
var w = maxX - minX;
var h = maxY-minY;
if (w > stopW && h > stopH) {
var centerX = random(minX+(w*.25), maxX-(w*.25));
var centerY = random(minY + (h*.25), maxY-(h*.25));
//fourQuads(minX, minY, centerX, centerY, maxX, maxY);
jokagbo(stopW, stopH, minX, minY, centerX, centerY); // NW
jokagbo(stopW, stopH, centerX, minY, maxX, centerY); // NE
jokagbo(stopW, stopH, minX, centerY, centerX, maxY); // SW
jokagbo(stopW, stopH, centerX, centerY, maxX, maxY); // SE
} else {
var centerX = random(minX+(w*.25), maxX-(w*.25));
var centerY = random(minY + (h*.25), maxY-(h*.25));
fourQuads(minX, minY, centerX, centerY, maxX, maxY);
}
}
function drawQuad(x1, y1, x2, y2, x3, y3, x4, y4) {
var c1 = deck();
var c2 = deck();
if (c1 == c2) {
colors[c1].fill(random(200));
colors[c1].stroke(random(50,255));
colors[c1].strokeWeight(random(0,2));
colors[c1].quad(x1, y1, x2, y2, x3, y3, x4, y4);
//console.log("samesame" + colors[c1].channelName + "," + colors[c2].channelName)
} else if (flipCoin()){
colors[c1].fill(random(200));
colors[c1].stroke(random(50,255));
colors[c1].strokeWeight(random(0,2));
colors[c1].fill(random(200));
colors[c1].stroke(random(50,255));
colors[c1].strokeWeight(random(0,2));
colors[c1].quad(x1, y1, x2, y2, x3, y3, x4, y4);
colors[c2].quad(x1, y1, x2, y2, x3, y3, x4, y4);
//console.log("overlap" + colors[c1].channelName + "-" + colors[c2].channelName + "@" + round(x1) + "," + round(y1));
} else {
colors[c1].fill(random(200));
colors[c1].stroke(random(50,255));
colors[c1].strokeWeight(random(0,2));
colors[c1].noFill();
colors[c1].stroke(random(50,255));
colors[c1].strokeWeight(random(1,3));
colors[c1].quad(x1, y1, x2, y2, x3, y3, x4, y4);
colors[c2].quad(x1, y1, x2, y2, x3, y3, x4, y4);
//console.log("alt" + colors[c1].channelName + "-" + colors[c2].channelName + "@" + round(x1) + "," + round(y1));
}
}
function fourQuads(sX, sY, cX, cY, eX, eY) {
if ((cX-sX) < 80 && (cY-sY) < 80) {
//colors[deck()].fill(0);
drawQuad(sX, sY, cX, sY, cX, cY, sX, cY) // NW
//drawQuad(sX, sY, cX, sY, cX, cY, sX, cY) // NW
} else if (flipCoin()) {
if ((cX-sX) > (cY-sY)) { // wide
var offset = (cX - sX)*.33;
var slant1 = random(sX + offset, cX - offset);
var slant2 = random(sX + offset, cX - offset);
//colors[0].fill(100);
drawQuad(sX, sY, slant1, sY, slant2, cY, sX, cY) // NW
drawQuad(slant1, sY, cX, sY, cX, cY, slant2, cY) // NW
} else if ((cX-sX) < (cY-sY)) { // tall
var offset = (cY - sY)*.33;
var slant1 = random(sY + offset, cY - offset);
var slant2 = random(sY + offset, cY - offset);
colors[deck()].fill(100);
drawQuad(sX, sY, cX, sY, cX, slant1, sX, slant2) // NW
drawQuad(sX, slant2, cX, slant1, cX, cY, sX, cY) // NW
}
} else { // straight
if ((cX-sX) > (cY-sY)) { // wide
var mid = sX + (cX - sX)/2;
var left = mid - sX;
var cLeft = sX + left/2;
var right = cX - mid;
var cRight = cX - right/2;
var height = cY-sY;
var cHeight = cY - height/2;
drawQuad(sX, sY, mid, sY, mid, cY, sX, cY) // NW
drawQuad(mid, sY, cX, sY, cX, cY, mid, cY) // NW
if (left > 60 && height > 60) {
//console.log('jasu L')
jasu(cLeft,cHeight);
}
if (right > 60 && height > 60) {
// console.log('jasu R')
jasu(cRight,cHeight);
}
} else if ((cX-sX) < (cY-sY)) { // tall
var mid = sY + (cY - sY)/2;
// var mid = sY + (cY-sY)/2;
var width = cX - sX;
var cWidth = sX + width/2;
var top = mid - sY;
var cTop = sY + top/2;
var bottom = cY - mid;
var cBottom = cY - bottom/2;
drawQuad(sX, sY, cX, sY, cX, mid, sX, mid) // NW
drawQuad(sX, mid, cX, mid, cX, cY, sX, cY) // NW
if (top > 60 && width > 60) {
// console.log('JASU-x-t')
jasu(cWidth,cTop);
}
if (bottom > 60 && width > 60) {
// console.log('JASU-x-b')
jasu(cWidth,cBottom);
}
}
}
if ((cX- sX) < 80 && (eY-cY) < 80) {
//colors[1].fill(255);
drawQuad(sX, cY, cX, cY, cX, eY, sX, eY) // SW
} else if (flipCoin()) {
if ((cX- sX) > (eY-cY) ) { // wide
var offset = (cX - sX)*.33;
var slant1 = random(sX + offset, cX - offset);
var slant2 = random(sX + offset, cX - offset);
drawQuad(sX, cY, slant1, cY, slant2, eY, sX, eY) // SW
drawQuad(slant1, cY, cX, cY, cX, eY, slant2, eY) // SW
} else if ((cX- sX) < (eY-cY)) { // tall
var offset = (eY-cY)*.33;
var slant1 = random(cY + offset, eY - offset);
var slant2 = random(cY + offset, eY - offset);
drawQuad(sX, cY, cX, cY, cX, slant1, sX, slant2) // SW
drawQuad(sX, slant2, cX, slant1, cX, eY, sX, eY) // SW
}
} else { // straight
if ((cX- sX) > (eY-cY) ) { // wide
var mid = sX + (cX - sX)/2;
var left = mid - sX;
var cLeft = sX + left/2;
var right = cX - mid;
var cRight = cX - right/2;
var height = eY-cY;
var cHeight = eY - height/2;
drawQuad(sX, cY, mid, cY, mid, eY, sX, eY) // SW
drawQuad(mid, cY, cX, cY, cX, eY, mid, eY) // SW
if (left > 60 && height > 60) {
//console.log('jasu!l')
jasu(cLeft,cHeight);
}
if (right > 60 && height > 60) {
// console.log('jasu!r')
jasu(cRight,cHeight);
}
} else if ((cX- sX) < (eY-cY)) { // tall
var mid = cY + (eY-cY)/2;
//var mid = sY + (cY-sY)/2;
var width = cX - sX;
var cWidth = sX + width/2;
var top = mid - cY;
var cTop = cY + top/2;
var bottom = eY - mid;
var cBottom = eY - bottom/2;
drawQuad(sX, cY, cX, cY, cX, mid, sX, mid) // SW
drawQuad(sX, mid, cX, mid, cX, eY, sX, eY) // SW
if (top > 60 && width > 60) {
//console.log('JASU__t')
jasu(cWidth,cTop);
}
if (bottom > 60 && width > 60) {
// console.log('JASU__b')
jasu(cWidth,cBottom);
}
}
}
if ((eX - cX) < 60 && (cY-sY) < 60) {
// colors[2].fill(255);
drawQuad(cX, sY, eX, sY, eX, cY, cX, cY) // NE
} else if (flipCoin()) {
if ((eX - cX) > (cY-sY)) { // wide
var offset = (eX - cX)*.33;
var slant1 = random(cX + offset, eX - offset);
var slant2 = random(cX + offset, eX - offset);
drawQuad(cX, sY, slant1, sY, slant2, cY, cX, cY) // NE
drawQuad(slant1, sY, eX, sY, eX, cY, slant2, cY) // NE
} else if ((eX - cX) < (cY-sY)) { // tall
var offset = (cY-sY)*.33;
var slant1 = random(sY + offset, cY - offset);
var slant2 = random(sY + offset, cY - offset);
drawQuad(cX, sY, eX, sY, eX, slant1, cX, slant2) // NE
drawQuad(cX, slant2, eX, slant1, eX, cY, cX, cY) // NE
}
} else { // straight
if ((eX - cX) > (cY-sY)) { // wide
var mid = cX + (eX - cX)/2;
//var mid = sX + (cX - sX)/2;
var left = mid - cX;
var cLeft = cX + left/2;
var right = eX - mid;
var cRight = eX - right/2;
var height = cY-sY;
var cHeight = cY - height/2;
drawQuad(cX, sY, mid, sY, mid, cY, cX, cY) // NE
drawQuad(mid, sY, eX, sY, eX, cY, mid, cY) // NE
if (left > 60 && height > 60) {
console.log('jasu--l')
jasu(cLeft,cHeight);
}
if (right > 60 && height > 60) {
console.log('jasu--r')
jasu(cRight,cHeight);
}
} else if ((eX - cX) < (cY-sY)) { // tall
var mid = sY + (cY-sY)/2;
var width = eX - cX;
var cWidth = cX + width/2;
var top = mid - sY;
var cTop = sY + top/2;
var bottom = cY - mid;
var cBottom = cY - bottom/2;
drawQuad(cX, sY, eX, sY, eX, mid, cX, mid) // NE
drawQuad(cX, mid, eX, mid, eX, cY, cX, cY) // NE
if (top > 60 && width > 60) {
//console.log('JASU....t')
jasu(cWidth,cTop);
}
if (bottom > 60 && width > 60) {
//console.log('JASU...b')
jasu(cWidth,cBottom);
}
}
}
if ((eX-cX) < 60 && (eY-cY) < 60) {
// colors[3].fill(255);
drawQuad(cX, cY, eX, cY, eX, eY, cX, eY) // SE
} else if (flipCoin()) {
if ((eX-cX) > (eY-cY)) { // wide
var offset = (eX - cX)*.33;
var slant1 = random(cX + offset, eX - offset);
var slant2 = random(cX + offset, eX - offset);
drawQuad(cX, cY, slant1, cY, slant2, eY, cX, eY) // SE
drawQuad(slant1, cY, eX, cY, eX, eY, slant2, eY) // SE
} else if ((eX-cX) < (eY-cY)) { // tall
var offset = (eY-cY)*.33;
var slant1 = random(cY + offset, eY - offset);
var slant2 = random(cY + offset, eY - offset);
drawQuad(cX, cY, eX, cY, eX, slant1, cX, slant2) // SE
drawQuad(cX, slant2, eX, slant1, eX, eY, cX, eY) // SE
}
} else { // straight
if ((eX-cX) > (eY-cY)) { // wide
var mid = cX + (eX - cX)/2;
var left = mid - cX;
var cLeft = cX + left/2;
var right = eX - mid;
var cRight = eX - right/2;
var height = eY-cY;
var cHeight = eY - height/2;
drawQuad(cX, cY, mid, cY, mid, eY, cX, eY) // SE
drawQuad(mid, cY, eX, cY, eX, eY, mid, eY) // SE
if (left > 60 && height > 60) {
console.log('jasu>>l')
jasu(cLeft,cHeight);
}
if (right > 60 && height > 60) {
console.log('jasu>>r')
jasu(cRight,cHeight);
}
} else if ((eX-cX) < (eY-cY)) { // tall
var dist = (eY-cY)
var mid = cY + (eY-cY)/2;
//var mid = sY + (cY-sY)/2;
var width = eX - cX;
var cWidth = cX + width/2;
var top = mid - cY;
var cTop = cY + top/2;
var bottom = eY - mid;
var cBottom = eY - bottom/2;
drawQuad(cX, cY, eX, cY, eX, mid, cX, mid) // SE
drawQuad(cX, mid, eX, mid, eX, eY, cX, eY) // SE
if (top > 60 && width > 60) {
// console.log('JASU***t')
jasu(cWidth,cTop);
}
if (bottom > 60 && width > 60) {
//console.log('JASU***b')
jasu(cWidth,cBottom);
}
}
}
/* test: basic 4 quadrants
quad(sX, sY, cX, sY, cX, cY, sX, cY) // NW
quad(sX, cY, cX, cY, cX, eY, sX, eY) // SW
quad(cX, cY, eX, cY, eX, eY, cX, eY) // SE
quad(cX, sY, eX, sY, eX, cY, cX, cY) // NE
*/
}
function solid3() {
colors[3].fill(255);
colors[3].noStroke();
}
function empty3() {
colors[3].noFill();
colors[3].stroke(255);
colors[3].strokeWeight(2);
}
function jasu(x,y) {
var flowers = round(random(0,4));
var petal = random(10,26);
if (flowers == 0) {
empty3();
colors[3].ellipse(x + petal*.5, y, petal, petal*.5);
colors[3].ellipse(x - petal*.5, y, petal, petal*.5);
colors[3].ellipse(x, y + petal*.5, petal*.5, petal);
colors[3].ellipse(x, y - petal*.5, petal*.5, petal);
solid3();
colors[3].ellipse(x,y, petal*.5, petal*.5);
} else if (flowers == 1) {
solid3();
var s = round(random(4,8));
var angle = TWO_PI / s;
for (var a = angle; a <= TWO_PI; a = a + angle) {
var cx = x + cos(a) * petal/2;
var cy = y + sin(a) * petal/2;
colors[3].ellipse(cx,cy, petal, petal);
}
colors[0].fill(255);
colors[0].noStroke();
colors[0].ellipse(x,y, 10, 10);
} else if (flowers == 2) {
solid3();
colors[1].fill(255);
colors[1].noStroke();
var s = 5;
var angle = TWO_PI / s;
for (var a = angle; a <= TWO_PI; a = a + angle) {
var cx = x + cos(a) * petal/2;
var cy = y + sin(a) * petal/2;
colors[3].ellipse(cx,cy, petal, petal);
var cx = x + cos(a) * petal/5;
var cy = y + sin(a) * petal/5;
colors[1].ellipse(cx,cy, petal*.25, petal*.25);
}
} else if (flowers == 3) {
colors[2].fill(255);
colors[2].noStroke();
var s = 5;
var angle = TWO_PI / s;
for (var a = angle; a <= TWO_PI; a = a + angle) {
var cx = x + cos(a) * petal/4;
var cy = y + sin(a) * petal/4;
colors[2].ellipse(cx,cy, petal*.33, petal*.33);
}
} else {
}
}
function deck() {
var randomno = round(random(0,3));
// console.log(options[randomno]);
return randomno;
}
function flipCoin() {
var tails = round(random(0,1));
//console.log(tails)
if(tails == 0){
return true;
} else {
return false;
}
}