xxxxxxxxxx
26
function createObject(x,y,radius) {
let newObj = {};
newObj.x = x;
newObj.y = y;
newObj.radius = radius;
newObj.draw = function() {
circle(this.x,this.y,2*this.radius);
}
return newObj;
}
let c1 = createObject(100,100,50);
let c2 = createObject(300,300,100);
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
c1.draw();
c2.draw();
}