Hi All,
My homework this week is about Classes. I can’t figure out how to get each of the three circles to be a different color. I am trying to make one red circle, one green circle, and one blue circle. They are all blue. I’ve tried push() and pop() just about everywhere and I’ve even tried noLoop().
Thank you!
let ball1;
let ball2;
let ball3;
function setup() {
createCanvas(500, 500);
background(175);
ball1 = new Ball(250, 275, 100, 255, 0, 0);
ball2 = new Ball(225, 225, 100, 0, 255, 0);
ball3 = new Ball(275, 225, 100, 0, 0, 255);
}
function draw() {
ball1.position();
ball2.position();
ball3.position();
ball1.looks();
ball2.looks();
ball3.looks();
}
class Ball {
constructor(x, y, z, r, g, b) {
this.x = x;
this.y = y;
this.z = z;
this.r = r;
this.g = g;
this.b = b;
}
position() {
noStroke();
ellipse(this.x, this.y, this.z);
}
looks() {
fill(this.r, this.g, this.b);
}
}