Passing arrays as arguments

i hope that i understand, not a array of class?

// https://discourse.processing.org/t/passing-arrays-as-arguments/6692

int[] myR = { 10,20,30,40,50 };

MyCircle ring = new MyCircle(0,0,myR);;

void setup() {
  size(200,200);
}

void draw() {
  background(200,200,0);
  translate(width/2,height/2);
  ring.drawit();  
}

class MyCircle {
  int posX,posY;
  int[] radius;
  MyCircle(int posX, int posY, int[] radius ) {
  this.posX = posX;
  this.posY = posY;
  this.radius = radius;
  }
  void drawit() {
   stroke(0,200,0);
   noFill();
   for (int i = 0; i<radius.length;i++) ellipse(posX,posY,radius[i],radius[i]);
  }
}

1 Like