sketchDownload/* Jiayi Chen
jiayiche Section A */
function setup() {
createCanvas(600, 600);
rectMode(CENTER);
}
function draw() {
background('gold');
for (var i=1;i<=6;i++){
for (var j=1;j<=6;j++){
repeatingPattern(i*200-150,j*200-50,100);
repeatingPattern(i*200-50,j*200-150,100);
repeatingPatternX(i*200-150,j*200-150,100);
repeatingPatternX(i*200-50,j*200-50,100);
}
}
repeatingPatternY(2*100-50,2*100-50,100);
repeatingPatternY(2*100-50,6*100-50,100);
repeatingPatternZ(5*100-50,4*100-50,100);
repeatingPatternZ(4*100-50,1*100-50,100);
noLoop();
}
function repeatingPattern(x,y,r){
// rect(x,y,r,r);
fourLines(x,y,r);
push();
fill('tomato')
circle(x,y,r*0.7);
pop();
push();
fill('khaki')
circle(x,y,r*0.65);
pop();
push();
fill('gold')
circle(x,y,r*0.6);
pop();
flower(x,y,r);
littleCircles(x,y,r)
}
function repeatingPatternX(x,y,r){
// rect(x,y,r,r);
fourLines(x,y,r);
push();
fill('tomato')
circle(x,y,r*0.7);
pop();
push();
fill('khaki')
circle(x,y,r*0.65);
pop();
push();
fill('gold')
circle(x,y,r*0.6);
pop();
flowerX(x,y,r);
littleCircles(x,y,r)
}
function repeatingPatternY(x,y,r){
// rect(x,y,r,r);
fourLines(x,y,r);
push();
fill('green')
circle(x,y,r*0.7);
pop();
push();
fill('cyan')
circle(x,y,r*0.65);
pop();
push();
fill('gold')
circle(x,y,r*0.6);
pop();
flowerX(x,y,r);
littleCirclesY(x,y,r)
}
function repeatingPatternZ(x,y,r){
// rect(x,y,r,r);
fourLines(x,y,r);
push();
fill('green');
circle(x,y,r*0.7);
pop();
push();
fill('cyan')
circle(x,y,r*0.65);
pop();
push();
fill('gold')
circle(x,y,r*0.6);
pop();
flower(x,y,r);
littleCirclesY(x,y,r)
}
function flower(x,y,r){
//leaves
push();
fill("lime");
triangle(x-r*0.03,y+r*0.14,x-r*0.1,y+r*0.18,x-r*0.15,y+r*0.13);
triangle(x+r*0.03,y+r*0.24,x+r*0.11,y+r*0.26,x+r*0.15,y+r*0.20);
pop();
//stems
push();
fill('gold');
bezier(x,y,x-r*0.1,y+r*0.2,x+r*0.1,y+r*0.2,x,y+r*0.3)
pop();
//petals
push();
fill('crimson');
ellipse(x-r*0.1,y-r*0.1,r*0.17,r*0.15);
ellipse(x+r*0.1,y-r*0.1,r*0.14,r*0.15);
ellipse(x,y-r*0.2,r*0.15,r*0.15);
ellipse(x-r*0.05,y,r*0.15,r*0.15);
ellipse(x+r*0.05,y,r*0.15,r*0.15);
pop();
//middle
push();
fill('orange');
circle(x,y-r*0.1,r*0.15);
pop();
}
function flowerX(x,y,r){
//leaves
push();
fill("lime");
triangle(x-r*0.03,y+r*0.14,x-r*0.1,y+r*0.18,x-r*0.15,y+r*0.13);
triangle(x+r*0.03,y+r*0.24,x+r*0.11,y+r*0.26,x+r*0.15,y+r*0.20);
pop();
//stems
push();
fill('gold');
bezier(x,y,x-r*0.1,y+r*0.2,x+r*0.1,y+r*0.2,x,y+r*0.3)
pop();
//petals
push();
fill('white');
ellipse(x-r*0.1,y-r*0.1,r*0.17,r*0.15);
ellipse(x+r*0.1,y-r*0.1,r*0.14,r*0.15);
ellipse(x,y-r*0.2,r*0.15,r*0.15);
ellipse(x-r*0.05,y,r*0.15,r*0.15);
ellipse(x+r*0.05,y,r*0.15,r*0.15);
pop();
//middle
push();
fill('orange');
circle(x,y-r*0.1,r*0.15);
pop();
}
function littleCircles(x,y,r){
doubleCircle(x-42,y-30,r*0.1);
doubleCircle(x-30,y-42,r*0.1);
doubleCircle(x+42,y+30,r*0.1);
doubleCircle(x+30,y+42,r*0.1);
doubleCircle(x+42,y-30,r*0.1);
doubleCircle(x+30,y-42,r*0.1);
doubleCircle(x-42,y+30,r*0.1);
doubleCircle(x-30,y+42,r*0.1);
}
function doubleCircle(x,y,r){
push();
fill('bisque');
circle(x,y,r);
circle(x,y,r/2);
pop();
}
function littleCirclesY(x,y,r){
doubleCircleY(x-42,y-30,r*0.1);
doubleCircleY(x-30,y-42,r*0.1);
doubleCircleY(x+42,y+30,r*0.1);
doubleCircleY(x+30,y+42,r*0.1);
doubleCircleY(x+42,y-30,r*0.1);
doubleCircleY(x+30,y-42,r*0.1);
doubleCircleY(x-42,y+30,r*0.1);
doubleCircleY(x-30,y+42,r*0.1);
}
function doubleCircleY(x,y,r){
push();
fill('purple');
circle(x,y,r);
circle(x,y,r/2);
pop();
}
function fourLines(x,y,r){
line(x-r/2,y-r/2,x-r*0.25,y-r*0.25);
line(x+r/2,y+r/2,x+r*0.25,y+r*0.25);
line(x+r/2,y-r/2,x+r*0.25,y-r*0.25);
line(x-r/2,y+r/2,x-r*0.25,y+r*0.25);
}