//Kyle Lee
//Section C
var x = 100;
var y = 100;
var h = 4;
var rowStart = 0;
var columnStart = 60;
var xSpace = 200;
var ySpace = 100;
function setup() {
createCanvas(600, 600);
background("#EBF8FF");//light blue
noStroke();
}
function draw(){
for (var y = 0; y < 6; y++) {
var evenOdd = y%2;//creates even or odd rows
if(evenOdd == 0) {//if row is even make 4 per row
rowStart = 0;
h = 4;
} else if(evenOdd == 1) {//if row is odd make 3 per row
h = 3;
rowStart = ySpace;
}//closes if else
for (var x = 0; x < h; x++) {
px = rowStart + x * xSpace;
py = columnStart + y * ySpace;
duck(px, py);
}//closes forloop
}//closes complete nested forloop
}//closes draw
function duck(x, y) {
push();
translate(x, y);
var headW = 50;
var headH = 40;
var headY = -30;
var bodyW = 40;
var bodyH = 30;
var wingW = 30;
var wingH = 10;
var mouthY = -20;
var mouthW = 13;
var mouthH = 8;
var eyeX = 10;
var eyeY = -35;
var eyeD = 7;
var footX = 7;
var footY = 16;
var footW = 8;
var footH = 4;
fill("#FAD438");//yellow
ellipse(0, headY, headW, headH);//head
ellipse(0, 0, bodyW, bodyH);//body
push();//right wing
rotate(radians(20));
ellipse(bodyH/2, 0, wingW, wingH);
pop();
push();//left wing
rotate(radians(-20));
ellipse(-bodyH/2, 0, wingW, wingH);
pop();
fill("#FF9D14");//orange
ellipse(0, mouthY, mouthW, mouthH);
fill("#534C45");//brown
ellipse(eyeX, eyeY, eyeD, eyeD);
ellipse(-eyeX, eyeY, eyeD, eyeD);
ellipse(footX, footY, footW, footH);
ellipse(-footX, footY, footW, footH);
pop();
noLoop();
}
For my project, I made a repeating pattern of ducks. I could definitely see this pattern on a pair of fun socks, or pj pants, or a short sleeve button up. I created a duck function in which I drew all the individual shapes. I then called upon that function in a for loop to repeat the pattern in a simple pattern.