xxxxxxxxxx
189
var clickCount;
var clickHeight = 0;
function setup() {
createCanvas(640, 360);
clickCount= 0;
input = createInput();
input.position(455, 180);
button = createButton("and that's okay");
button.position(input.x+20, input.y+input.height);
button.mousePressed(greet);
greeting = createElement('h2', 'What have you done today?');
greeting.position(440, 70);
greeting.size(180);
greeting.style('text-align', 'center');
textAlign(CENTER);
textSize(50);
}
function greet() {
const name = input.value();
greeting.html('I am proud of you! What else?');
input.value('');
for (let i = 0; i < 200; i++) {
push();
fill(random(255), 255, 255);
translate(random(width), random(height));
rotate(random(2 * PI));
text(name, 0, 0);
pop();
}
clickCount = clickCount+1;
}
function draw() {
background(250,250,250);
clickHeight = clickCount* 10;
if (clickHeight >= 120) {
clickHeight=120;
}
//window
fill(213, 219, 214);
stroke(250,250,250);
line(0,269,640,185);
noStroke();
rect(390,0,40,300,0);
//left window
rect(0,0,350,180);
strokeWeight(20);
stroke(213, 219, 214);
line(0,220,340,180);
strokeWeight(30)
line(0,195,250,180);
//left window details
fill(240, 249, 255);
noStroke();
quad(-20,-20, 300, 0, 300, 160, 0, 190);
// stroke(235, 255, 235);
//rect(-20,-20,350,200,50);
// stroke(92, 196, 94,100);
// line(-10,100,(millis()/270),160)
// stroke(250, 250, 250);
// line(0,0,270,160)
// line(220,-10,0,160)
strokeWeight(10);
stroke(196, 196, 196);
line(150,0,150,160);
line(0,110,285,90);
//right window
fill(233, 240, 234);
noStroke();
// rect(460,0,200,150);
//plant seat
stroke(240, 245, 241);
strokeWeight(20);
//line(0,250,640,0);
stroke(196, 196, 196);
strokeWeight(50);
line(0,320,640,230);
strokeWeight(30);
stroke(210,210,210);
line(0,350,640,270);
stroke(235, 235, 235);
line(0,380,640,300);
strokeWeight(60);
line(0,400,640,330);
//pot
//shadow
noStroke();
fill(168, 167, 167);
ellipse(210,290,130,20);
//behind dirt light
noStroke();
fill(212, 106, 163);
rect(205,155,110,43,20);
//behind dirt dark
// noStroke();
// fill(133, 65, 102);
// ellipse(260,174,110,40);
//wittle dirt
fill(89, 63, 21,200);
ellipse(260,210,120,120);
//pot
fill(250, 137, 200);
rect(200,160,120,130,20);
//highlight
fill(255, 237, 247);
ellipse(290,200,15,40);
//calling plant
plant(clickHeight);
//shadow
//window
//text bubble
fill(205, 73, 245,130);
rect(430,10,200,250,120);
//button();
// fill(255, 219, 135);
// rect(480,200,100,50,150);
// fill("blue");
// text("button",511,230);
}
function leaf(x, y,rotation) {
push();
rectMode(CENTER);
translate(x, y);
angleMode(DEGREES);
rotate(rotation);
fill(46, 133, 64,220);
rect(0, 0, 30, 50,15);
strokeWeight(5);
stroke(109, 173, 122);
line(0, -20, 0, 20);
pop();
}
function plant(plantHeight) {
//stem
noStroke();
fill(130, 93, 34); rect(257,150-plantHeight,10,plantHeight+10,5);
if (clickHeight > 80) {
leaf(250, 50, 50);
leaf(250, 120,100);
leaf(270, 80, 50);
}
if (clickHeight >= 30 && clickHeight< 40) {
fill(46, 133, 64);
rect(0, 0, 30, 50,15);
strokeWeight(5);
stroke(109, 173, 122);
line(0, -20, 0, 20);
}
}
function mousePressed(){
if (mouseX > 480 && mouseX < 580 && mouseY > 200 && mouseY < 250) {
clickCount = clickCount+1;
}
}