Project-05

I started with some shapes and it turned into something pretty cool.

Project-05
//Luke Mattson
//section A





function setup(){
	createCanvas(600, 600);
    background(224, 201, 166)
}


function draw() {
    //drawing the hexagons
   for (x = 40; x < 600; x += 87) {
        for (y = 55; y < 600; y+=160) {
            hexagon(x,y,30)
            hexagon(x,y,40)
        }
    }
    for (x = -5; x < 700; x += 87) {
        for (y = -25; y < 700; y+=160) {
            hexagon(x,y,30)
            hexagon(x,y,40)
        }
    }

    //drawing the triangles in between the hexagons
    for (x = -3.5; x < 700; x += 87) {
        for (y = 53; y < 700; y+=160) {
            trianglePair(x,y)
        }
    }
    for (x = 39; x < 700; x += 87) {
        for (y = -27; y < 700; y+=160) {
            trianglePair(x,y)
        }
    }

    //drawing pumkins inside the hexagons
    for (x = 41; x < 700; x += 87) {
        for (y = 57; y < 700; y+=160) {
            pumpkin(x,y)
        }
    }
    for (x = -5; x < 700; x += 87) {
        for (y = 137; y < 700; y+=160) {
            pumpkin(x,y)
        }
    }
    noLoop()
}

function hexagon(x,y,s) {
    stroke(210,83,73)
    strokeWeight(.5)
    noFill()
    beginShape()
    vertex(x+s,y)
    vertex(x+s/2,y+s*sqrt(3)/2)
    vertex(x-s/2,y+s*sqrt(3)/2)
    vertex(x-s,y)
    vertex(x-s/2,y-s*sqrt(3)/2)
    vertex(x+s/2,y-s*sqrt(3)/2)
    endShape(CLOSE)
}

function trianglePair(x,y) {
    fill(210,83,73)
    triangle(x,y,x-23,y-40,x+23,y-40)
    triangle(x,y+4,x-23,y+44,x+23,y+44)
}

function pumpkin(x,y) {
  pHeight = 30
  pWidth = 40 

  //stem
  strokeWeight(2)
  stroke(0, 150, 0);
  line(x, y-pHeight/2, x-pWidth/4, y - pHeight*.75);
 
  //pumpkin
  strokeWeight(1);
  fill(230, 100, 0);
  stroke(120, 60, 0);
  ellipse(x,y, pWidth, pHeight);
  ellipse(x,y, pWidth*.75, pHeight);
  ellipse(x,y, pWidth*.5, pHeight);
  ellipse(x,y, pWidth*.25, pHeight);
}

Leave a Reply