xxxxxxxxxx
158
//Title:Happy Sunflower
//Artist: An
//Description: This sunflower is not happy when the sun moves away.
/* 1.draw a sunflower.
2.sunflower's face turns based on second()
3.the background change through time.
*/
let var1;
let spd;
let r;
let g;
let b;
function preload(){
img = loadImage('Cloud-02.png');
}
function setup() {
createCanvas(600, 600);
var1=370;
spd=1;
a=0;
}
function draw() {
//BACKGROUND
//blendMode(MULTIPLY);
background(200,5,50);
push();
background(10,220,225,var1-200);
fill(225,225,225,var1-200);
tint(225,var1-200);
image(img, 20, 10, 300, 200);
image(img, 420, 10, 280, 150);
pop();
let s = second();
console.log(s);
//STEM
push();
blendMode(DARKEST);
fill(100,225,0);
noStroke();
rect(300,400,20,300);
ellipse(230,450,150,100);
ellipse(375,500,100,90);
rect(350,500,100,10);
pop();
//SUNFLOWER
noStroke();
push();
rectMode(CENTER);
push();
a=200
translate(300,300);
fill(255,211,0);
circle(0,100,100);
push();
rotate(TWO_PI/8);
circle(0,100,100);
pop();
push();
rotate(TWO_PI*2/8);
circle(0,100,100);
pop();
push();
rotate(TWO_PI*3/8);
circle(0,100,100);
pop();
push();
rotate(TWO_PI*4/8);
circle(0,100,100);
pop();
push();
rotate(TWO_PI*5/8);
circle(0,100,100);
pop();
push();
rotate(TWO_PI*6/8);
circle(0,100,100);
pop();
push();
rotate(TWO_PI*7/8);
circle(0,100,100);
pop();
pop();
push();
fill(255,165,0);
circle(width/2,300,200);
pop();
//FACE
fill(0);
b=100
rect(250,260,20,40,10,10,10,10);
rect(250+b,260,20,40,10,10,10,10);
stroke(0,0,0);
strokeWeight(7);
noFill();
var1+=spd;
bezier(250,330,275,var1,250+b-25,var1,250+b,330);
//MOUTH CHANGE
if(var1>370||var1<300||s>5){
spd*=-1;
}else {
spd*=1;
}
//TEAR
if(300<var1<350){
fill(225);
}else{
noFill();
}
noStroke();
l=350-var1;
if(var1<350){
rect(250,280,l,10,5,5,5,5);
rect(250+b,280,l,10,5,5,5,5);
}else{
l=0
}
//console.log(`it is ${s}second`);
}