sketch
//Hayoon Choi
//hayoonc
//Section C
var starx = [];
var stary = [];
var starr = [];
function setup() {
createCanvas(480, 480); //making the stars stay in position
for( var i = 0; i <= 300; i++){
starx[i] = random(width);
stary[i] = random(height);
starr[i] = random(3);
}
}
function draw() {
background(0);
//drawing stars in the background
fill(255, 252, 235);
noStroke();
for( var i = 0; i <= 300; i++){
circle(starx[i], stary[i], starr[i])
}
flame(240, 240);
sun(240, 240);
blush(240, 240);
eyelash(240, 240);
eyelash(160, 240);
}
function sun(x, y){
push();
translate(x, y);
noStroke();
fill(237, 227, 183);
circle(0, 0, 200); //head
//eyes
fill(255);
stroke(0);
ellipse(30, -24, 31, 12);
ellipse(-50, -24, 31, 12);
fill(0);
circle(30, -24, 5);
circle(-50, -24, 5);
//mouth
noStroke();
fill(234, 136, 173);
arc(-5, -16, 15, 10, PI, 2 * PI);
arc(-15, -16, 15, 10, PI, 2 * PI);
arc(-10, -16, 25, 20, 0, PI);
fill(255);
circle(-2, -13, 3)
//mole
fill(0);
circle(5, -4, 3)
pop();
}
function blush(x, y){ //seconds
let s = second();
push();
translate(x, y);
rotate(radians())
fill(234, 97, 66);
noStroke();
let secondH = map(s, 0, 60, 0, 360);
arc(30, -5, 30, 20, 0, -secondH);
arc(-56, -5, 30, 20, 0, -secondH);
pop();
}
function eyelash(x, y){ //minutes
//eyelashes grow by minutes
let m = minute();
push();
translate(x, y);
stroke(0);
for (var i = 0; i < m; i ++) {
line(18.5, -29, 18.5, -29 + (-0.5 * i));
line(30, -31, 30, -31 + (-0.5 * i));
line(41.5, -29, 41.5, -29 + (-0.5 * i));
}
pop();
}
function flame(x, y){ //hours
//the color of flame changes each hour one by one
var hournow = hour() % 12 + 1; //restarts after 12 hours
push();
translate(x, y);
//red flame
scale(2);
for (var i = 0; i < hournow; i++){
push();
fill(221, 54, 54);
rotate(radians(30 * i - 90));
noStroke();
ellipse(50, 0, 45, 25);
pop();
}
//orange flame
for (var i = hournow; i < 12; i++){
push();
fill(255, 149, 62);
rotate(radians(30 * i - 90));
noStroke();
ellipse(50, 0, 45, 25);
pop();
}
pop();
}
I wanted to create a sun in space. The color of each flame changes after one hour, the eyelashes grow taller by minutes, and the blushes fill up by seconds.