xxxxxxxxxx
38
/* Fun with variables and objects
Code by Daniel Weiner
Based on examples by Coding Train
Practice using variables and JS objects to change properties of a p5.js ellipse
*/
// declare and initialize variables
let r = 218;
let g = 160;
let b = 221;
// let diameter = 50;
// let x = 0;
// let y = 200
// Use a JS object named circle
let circle = {
x: 0,
y: 100,
diameter: 50
}
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
// use object to for fill and ellipse
fill(r, g, b)
ellipse(circle.x, circle.y, circle.diameter, circle.diameter)
// move ellipse across the screen
circle.x = circle.x + 1
}