xxxxxxxxxx
32
var position = {
x: 200,
y: 200
};
var color = {
r: 0,
g: 0,
b: 0
};
function setup() {
createCanvas(400, 400);
background(0);
}
function draw() {
//set a random x,y position
position.x = random(10,390);
position.y = random(10, 390);
//map position of spot to a color value. The greater the
//x-position, the whiter the spot
color.r = map(position.x, 10, 390, 0, 255)
color.g = color.r
color. b = color.r
noStroke();
fill(color.r, color.g, color.b)
ellipse(position.x, position.y, 25);
}