xxxxxxxxxx
99
function setup() {
//setupA(); //colorful elipses
//setupB(); //
setupC(); //
}
function draw() {
//drawA();
//drawB();
drawC();
}
//C
let dots = [];
function setupC() {
createCanvas(400,400);
for (let i = 0; i < 40; i++)
{
let x = random(width);
let y = random(height);
let d = random(30, 80);
let c = color(random(["blue", "red", "yellow"]));
dots.push({
x: x, y: y, d: d, c: c
});
}
}
function drawC() {
background(255);
// for (let i = 0; i < dots.length; i++)
// {
// fill(dots[i].c);
// stroke(255);
// strokeWeight(5);
// ellipse(dots[i].x, dots[i].y, dots[i].d);
// }
for (let d of dots)
{
fill(d.c);
stroke(255);
strokeWeight(5);
ellipse(d.x, d.y, d.d);
}
}
function mousePressed() {
dots = [];
for (let i = 0; i < 40; i++)
{
let x = random(width);
let y = random(height);
let d = random(30, 80);
let c = color(random(["blue", "red", "yellow"]));
dots.push({
x: x, y: y, d: d, c: c
});
}
}
//A
function setupA() {
createCanvas(400, 400);
}
let colors = [
{r: 150, g: 40, b: 200},
{r: 250, g: 40, b: 140},
{r: 50, g: 240, b: 100},
{r: 150, g: 240, b: 140},
{r: 250, g: 240, b: 200},
{r: 50, g: 40, b: 240},
];
function drawA() {
background(20);
let spacing = 20;
for (let x = 0; x<= width; x+= spacing)
{
for (let y = 0; y<= height; y+= spacing)
{
let index = int(random(colors.length));
//fill(colors[index].r, colors[index].g, colors[index].b);
//fill(int(random(250)), int(random(250)), int(random(250)));
ellipse(x,y,spacing);
}
}
}