xxxxxxxxxx
85
// this variable is global
var y;
var circleR;
count = 0;
function setup() {
createCanvas(800, 600);
y = height / 2;
background(0);
// drawCircle(10,50,100);
flower(400,300,100);
}
function draw() {
noFill();
noLoop();
// drawCircle(width/2, height/2, 300);
flower();
// // Circle Motion
// circleD = 100
// circleR= circleD/2;
// background(255);
// noStroke();
// fill(255, 100, 200, 100);
// ellipse(width/2, y, circleD, circleD);
// // update the vertical location and make the cicle bounce
// count += 1;
// y = (height/2) + (sin(count/10) * 150);
// y += 1;
// if(y > height+ circleR){
// y = 0;
// }
// //NESTED FOR LOOP
// var r = 0;
// var g = 0;
// var b = 0;
// for (var y = 20; y < height; y += 40) {
// for (var x = 20; x < width; x += 40) {
// fill(r, g, b);
// r = r + 1;
// g = g + 1;
// b = b + 1;
// stroke(y);
// strokeWeight(2);
// ellipse(x, y, 40, 40);
// }
// }
} // end of draw function
//Flower function!🌼
function flower(x, y, size) {
fill(246, 255, 66);
stroke(255);
strokeWeight(2);
ellipse(x, y, size, size);
fill(255, 100, 200, 100);
var new_size = size / 2;
ellipse(x + new_size, y, new_size, new_size);
ellipse(x - new_size, y, new_size, new_size);
ellipse(x, y + new_size, new_size, new_size);
ellipse(x, y - new_size, new_size, new_size);
}
//Recusive Circle Function 🌚
// function drawCircle(x, y, size) {
// ellipse(x, y, size, size);
// if (size > 10) {
// var new_size = size/2 ;
// stroke(random(250));
// strokeWeight(1);
// drawCircle(x + random(new_size), y, new_size);
// drawCircle(x - random(new_size), y, new_size);
// drawCircle(x, y + random(new_size), new_size);
// drawCircle(x, y - random(new_size), new_size);
// }
// }