xxxxxxxxxx
479
function setup() {
createCanvas(600, 600);
}
function draw() {
background(255);
if (mousePressed() && mouseDragged() &&mouseReleased()){
///nothing
} else {
push();
noLoop();
noStroke();
fill(240,240,240,200);
rect(0,0,600,600)
fill('white');
rectMode(CENTER);
rect(width/2,height/2,470,40,20);
rectMode(CORNER);
fill('black');
noStroke();
textFont('Georgia');
textSize(30);
text("Hold down mouse to generate tile", 77, 287, width, height);
textSize(20);
text("**Bonus: Can you spot the Maltese Cross?", 175, 565, width, height);
pop();
push();
noStroke();
fill('black');
translate(570,570);
for (let i = 0; i < 4; i++) {
angleMode(DEGREES);
rotate(90);
quad(0, 0, -10, -20, 0, -10, 10, -20);}
pop();
}
}
function mouseReleased(){
noLoop();
randomTile();
}
function mouseDragged() {
loop();
randomTile();
}
function mousePressed(){
loop();
randomTile();
}
function randomTile(){
push();
blendMode(BLEND);
fill(255);
rect(0,0,600,600);
pop();
/////color random variables
let rColor1 = random(255);
let rColor2 = random(100,250);
let rColor3 = random(100, 200);
let rColor4 = random(110,250);
let rColor5 = random(20, 100);
let rColor6 = random(4,100);
////random int
let r = int(random(2));
let rborder = int(random(3));
let r1 = int(random(1));
let r2 = int(random(3));
let r3 = int(random(3));
let r4 = int(random(2));
let r5 = int(random(3));
fill(rColor1, rColor4, rColor1);
stroke(rColor3-100,rColor4, rColor6);
///////////////////////////////////MIDSHAPE
if (r4==0){
midShape1();
}
if (r4==1){
fill(255);
midShape2();
}
if (r4==2){
//none
}
fill(rColor3, rColor4, rColor1);
stroke(rColor3-100,rColor4, rColor1);
///////////////////////////////////CENTER *FRILLS*
if (r3==1){
frills2();
}
if (r3==2){
frills3();
}
if (r3==3){
frills4();
}
if (r3==0){
frills1();
}
fill(rColor3, rColor2, rColor6);
stroke(rColor3-100,rColor2, rColor4);
///////////////////////////////CORNER SHAPES
if (r5==0){
cornerShape1();
}
if (r5==1){
cornerShape2();
}
if (r5==2){
cornerShape3();
}
if (r5==3){
cornerShape4();
}
fill(rColor3, 0, rColor6);
stroke(rColor1,rColor4-100, rColor1);
////////////////////////////RANDOM BORDERS
if (rborder==0){
border1();
}
if (rborder==1){
border2();
}
if (rborder==2){ //no border
}
if (rborder==3){ //no border
}
//////////RANDOM CORNERS
if (r==0){
corner1();
}
if (r==1){
corner2();
}
malteseCross();
///////////////////////////////////RANDOM CENTER LINES
if (r2==0){
centerLines1();
}
if (r2==1){
malteseCross();
}
if (r2==2){
centerLines2();
}
if (r2==3){
ellipse(width/2,height/2,random(10,100));
}
malteseCross();
push(); ///overlay for cohesive color
blendMode(OVERLAY);
noStroke();
fill(rColor1, rColor2, rColor3,200);
rect(0,0,600,600);
pop();
push();
blendMode(DARKEST);
strokeWeight(20);
stroke(30,30,30,50);
fill(130, 117, 103,150);
rect(0,0,600,600);
strokeWeight(5);
for (let x=0; x<2; x++){
for(let y=0; y<2; y++){
strokeWeight(5);
stroke(30,30,30,10);
noFill();
rect(300*x, 300*y, 300, 300);
}
}
pop();
}
///////////////////////////////////////BORDERS
function border1() {
var border1Size = random(30,150);
push();
strokeWeight(random(1,20));
for (let x = 0; x < 20; x++) {
ellipse(1+border1Size*x,0,border1Size); ///top border
ellipse(1+border1Size*x,599,border1Size); ///bottom border
}
for (let y = 0; y < 20; y++) {
ellipse(1,0+border1Size*y,border1Size); ///left border
ellipse(600,0+border1Size*y,border1Size); ///right border
}
pop();
}
function border2() {
let randomSquareSize = random(20,100);
let randomSquareRadius = random(0,20);
push();
strokeWeight(random(1,20));
for (let x = 0; x < 50; x++) {
rectMode(CENTER);
rect(0+randomSquareSize*x, 0, randomSquareSize, randomSquareSize, randomSquareRadius); //top
rect(0+randomSquareSize*x, 599, randomSquareSize, randomSquareSize, randomSquareRadius); //bottom
for (let y = 0; y < 50; y++) {
rect(0, 0+randomSquareSize*y, randomSquareSize, randomSquareSize, randomSquareRadius); //left
rect(599, 0+randomSquareSize*y, randomSquareSize, randomSquareSize, randomSquareRadius); //right
}
}
pop();
}
/////////////////////////////////////////////////////////////////CORNERS
function corner1(){
push();
strokeWeight(random(1,9));
for (let x = 0; x < random(1,15); x++) {
ellipse(0,0,200-(x*20)); ///topleft
ellipse(600,0,200-(x*20)); ///topright
ellipse(0,600,200-(x*20)); ///botleft
ellipse(600,600,200-(x*20)); ///botright
}
pop();
}
function corner2() {
push();
strokeWeight(random(1,9));
rectMode(CENTER);
for (let x = 0; x < random(1,15); x++) {
rect(0,0,200-(x*20)); ///topleft
rect(600,0,200-(x*20)); ///topright
rect(0,600,200-(x*20)); ///botleft
rect(600,600,200-(x*20)); ///botright
}
pop();
}
///////////////////////////////////////CENTERLINES
function centerLines1(){
push();
let lineLength = random(4,100);
let lineWidth = random(2);
strokeWeight(random(1,9));
angleMode(DEGREES);
translate(width/2,height/2);
for (let i = 0; i < 10; i++) {
rotate(40);
rect(15,15,lineLength,lineLength*lineWidth);
}
pop();
}
function centerLines2(){
let lineLength = random(4,100)
let lineWidth = random(4,100)
strokeWeight(random(1,9));
push();
angleMode(DEGREES);
ellipseMode(CORNER);
translate(width/2,height/2);
for (let i = 0; i < 10; i++) {
rotate(60);
ellipse(0,0,lineLength,lineWidth);
}
pop();
}
///////////////////////////////////////FRILLS
function frills1(){
let randomBez = random(100);
let randomBez1 = random(300);
let randomBez2 = random(300);
let randomBez3 = random(80);
push();
strokeWeight(random(1,9));
translate(width/2, height/2);
angleMode(DEGREES);
for (let i = 0; i < 8; i++) {
rotate(45);
beginShape();
vertex(30, 20);
bezierVertex(randomBez, randomBez3, randomBez3, 150, randomBez2, randomBez1);
endShape(CLOSE);
}
pop();
}
function frills2(){
let rectWidth = random(10,50)
let rectLength = random(5,200)
strokeWeight(random(1,9));
push();
rotate(90);
rect(width/2-rectWidth/2,height/2,rectWidth);
pop();
}
function frills3(){
strokeWeight(random(1,30));
ellipse(width/2,height/2, random(20,400));
}
function frills4(){
let w = random(100);
let h = random(300);
push();
strokeWeight(random(1,9));
translate(width/2, height/2);
angleMode(DEGREES);
for (let i = 0; i < 4; i++) {
rotate(90);
beginShape();
vertex(30, 20);
bezierVertex(-w+200, -h+200, w+200, h, w, 0);
endShape(CLOSE);
}
pop();
}
function midShape1(){
rectSize = random(400);
rectCurve = random(20);
push();
strokeWeight(random(1,40));
translate(width/2,height/2);
rectMode(CENTER);
rotate(random(90));
rect(0,0,rectSize,rectSize,rectCurve);
pop();
}
function midShape2(){
push();
strokeWeight(random(1,30));
for (let x=0; x<2; x++){ /////////NESTED forloop
for(let y=0; y<2; y++){
rect(300*x, 300*y, 300, 300);
}
}
pop();
}
function cornerShape1(){
let randomVertexTip = random(80,200);
push();
beginShape();
vertex(0, 0);
bezierVertex(0, 100, 100, 80, randomVertexTip, randomVertexTip);
bezierVertex(randomVertexTip, randomVertexTip, 100, 80, 100, 0);
endShape();
pop();
push();
translate(600,0);
beginShape();
vertex(600, 0);
bezierVertex(0, 100, -100, 80, -randomVertexTip, randomVertexTip);
bezierVertex(-randomVertexTip, randomVertexTip, -100, 80, -100, 0);
endShape();
pop();
push();
translate(0,600);
beginShape();
vertex(0, 0);
bezierVertex(0, -100, 100, -80, randomVertexTip, -randomVertexTip);
bezierVertex(randomVertexTip, -randomVertexTip, 100, -80, 100, -0);
endShape();
pop();
push();
translate(600,600);
beginShape();
vertex(0, 0);
bezierVertex(-0, -100, -100, -80, -randomVertexTip, -randomVertexTip);
bezierVertex(-randomVertexTip, -randomVertexTip, -100, -80, -100, -0);
endShape();
pop();
}
function cornerShape2(){
push();
let cornerSize = random(440);
let cornerCurve = random(5,30);
rectMode(CENTER);
rect(0,0,cornerSize,cornerSize,cornerCurve);
rect(600,0,cornerSize,cornerSize,cornerCurve);
rect(0,600,cornerSize,cornerSize,cornerCurve);
rect(600,600,cornerSize,cornerSize,cornerCurve);
pop();
}
function cornerShape3(){
push();
let cornerSize = random(100,440);
let cornerCurve = random(600);
ellipse(0,0,cornerSize,cornerCurve);
ellipse(600,0,cornerSize,cornerCurve);
ellipse(0,600,cornerSize,cornerCurve);
ellipse(600,600,cornerSize,cornerCurve);
pop();
}
function cornerShape4(){
push();
let circleSize = random(20,300);
ellipse(100,100,circleSize);
ellipse(500,100,circleSize);
ellipse(100,500,circleSize);
ellipse(500,500,circleSize);
pop();
}
function malteseCross() {
let malteseCrossR = random(20,280);
push();
blendMode(OVERLAY);
translate(width/2,height/2);
for (let i = 0; i < 4; i++) {
angleMode(DEGREES);
rotate(90);
quad(0, 0, -malteseCrossR/2, -malteseCrossR, 0, -malteseCrossR/2, malteseCrossR/2, -malteseCrossR);}
pop();
}