color();

Does anyone know why the color function isn't working here? I've tried a ton of stuff.

x = 0;
y = 200;
rad = 10;
col = color(255, 0, 100); 
var bubble = {
      x: 150,
      y: 200,
      r: 50,
      display: function() {
         noStroke();
         fill(col);
         ellipse(this.x, this.y, this.r, this.r);
         ellipse(this.x*2, this.y, this.r, this.r);
         ellipse(this.x*3, this.y, this.r, this.r);
         ellipse(this.x*4, this.y, this.r, this.r);
  }
}

function setup() {
     createCanvas(800, 400);

}

function draw() {
      background(200);
      bubble.display();
      noStroke();  
      fill(0);  
      ellipse(x, y, rad, rad); 
          x += 2;
}
Tagged:

Answers

  • edited March 2017 Answer ✓

    Hi again, I put:

    col = color(255, 0, 100); 
    

    in setup and it worked.

  • It is a good habit to init all your objects and variables in setup. That is the reason it is there in the first place. However, most people opt not to do it... personal preference I suppose...

    Glad you figure it out! :ar!

    Kf

Sign In or Register to comment.