jwchou-project03-dynamicdrawing

sketch 285

//Jackie Chou
//Section E
//jwchou@andrew.cmu.edu
//Project-Week-03

var bkgndR = 241;
var bkgndG = 240;
var bkgndB = 120;
var appleR = 241;
var appleG = 98;
var appleB = 72;

function setup() {
    createCanvas(640, 480);
}

function draw() {
	background(bkgndR, bkgndG, bkgndB);
	noStroke();

    push();
    //rotates apple at the end when mouseX >500
    if (mouseX > 500) {
        translate(670, -50);
        rotate(PI/2.01);
    }

	//stem   
	fill(96, 47, 7);
	beginShape();
	curveVertex(311, 176);
	curveVertex(325, 169);
	curveVertex(323, 137);
	curveVertex(333, 111);
	curveVertex(325, 99);
	curveVertex(315, 106);
	curveVertex(318, 115);
	curveVertex(315, 130);
	curveVertex(312, 146);
	curveVertex(312, 176);
	endShape();

	//apple
	fill(appleR - 0.046 * mouseX, appleG + 0.1109 * mouseX, appleB + 0.09166 * mouseX);
    beginShape();
    curveVertex(315, 149);
    curveVertex(308, 149);
    curveVertex(285, 143);
    curveVertex(257, 149);
    curveVertex(236, 161);
    curveVertex(201, 218);
    curveVertex(214, 311);
    curveVertex(273, 371);
    curveVertex(323, 373);
    curveVertex(354, 376);
    curveVertex(399, 358);
    curveVertex(443, 283);
    curveVertex(451, 236);
    curveVertex(430, 177);
    curveVertex(376, 141);
    curveVertex(338, 140);
    curveVertex(315, 149);
    endShape();

    //bite one when mouseX > 40
    if (mouseX > 40) {
      fill(bkgndR, bkgndG, bkgndB);
      ellipse(440, 170, 80, 80);
    }

    //bite two when mouseX > 80
    if (mouseX > 80) {
      fill(bkgndR, bkgndG, bkgndB);
      ellipse(425, 230, 70, 90);
    }

    //bite three when mouseX > 20
    if (mouseX > 20) {
      fill(bkgndR, bkgndG, bkgndB);
      ellipse (200, 260, 70, 90);
    }

    //bite four when mouseX > 60
    if (mouseX > 60) {
      fill(bkgndR, bkgndG, bkgndB);
      ellipse (210, 290, 80, 60);
    }

    //bite five when mouseX > 200
    if (mouseX > 200) {
      fill(bkgndR, bkgndG, bkgndB);
      ellipse (430, 300, 100, 100);
    }

    //bite six when mouseX > 150
    if (mouseX > 150) {
      fill(bkgndR, bkgndG, bkgndB);
      ellipse (200, 160, 130, 130);
    }

    //bite seven when mouseX > 280
    if (mouseX > 280) {
      fill(bkgndR, bkgndG, bkgndB);
      ellipse (428, 270, 120, 90);
    }

    //bite eight when mouseX and seed one > 320
    if (mouseX > 320) {
      fill(bkgndR, bkgndG, bkgndB);
      ellipse (210, 250, 110, 100);
      fill(140, 98, 57);
      ellipse (300, 235, 12, 25);
    }

    //bite nine and seed two when mouseX > 400
    if (mouseX > 400) {
      fill(bkgndR, bkgndG, bkgndB);
      ellipse (215, 300, 96, 96);
      fill(140, 98, 57);
      ellipse (315, 255, 12, 25);
    }

    //bite ten and seed three when mouseX > 450
    if (mouseX > 450) {
      fill(bkgndR, bkgndG, bkgndB);
      ellipse (415, 160, 90, 105);
      fill(140, 98, 57);
      ellipse (325, 225, 12, 25);
    
    }
    pop();




}

For this project, I started with an idea that I would have a plane take off and land as mouseX moved from left to right. However, I realized that I probably did not have the coding skill to pull it off successfully because I didn’t know how to make a complex object expand/shrink in size.

I was thinking of a good chronological visual, and the idea of having an apple being eaten made sense to me. I used mouseX and background-colored ellipses to convey bites being taken out of the apple. I tried making the background change color as well, but it ultimately distracted from the apple.

Leave a Reply