Arrays to draw lines

Hey there!

I’ve got a question. I’m trying connect the flowers in my code with (curvy) lines behind them. In order to do that I have to determine the x and the y values of where my flowers are drawn, but since they are drawn at a random place it’s kinda hard to determine where the lines have to start. I tried to use arrays but it does not work yet and I don’t really understand why it doesn’t work (I’m only a beginner so It’s still hard for me to correct my errors). another problem is that I wanted a nice transition of big flowers at the bottom and small ones at the top. before I started working with arrays to draw the flowers, it worked perfectly but now there are only two flower sizes. also strange is that there are little black dots in the left corner that weren’t there before, and the flowers are not spread over the whole height anymore. Is there somebody who could help me? this is my code:

int r = 10;
int a;
int d;

int [][] lines;
float[][]distances;
float maxDistance;
int spacer;

void setup() {
  size(800, 1000);
  maxDistance = dist(width/2, height/2, width, height);
  distances = new float[width][height];
  lines = new int[width*height][4];
  for (int o = 0; o< height; o++) {
    for (int p = 0; p<width; p++) {
      float distance = dist(width/2, height/10, p, o);
      distances[p][o] = distance/maxDistance * 255;
    }
  }
  spacer = 3;
  strokeWeight(6);
  noLoop();
}

void draw() {
  background(0);
  for (int o = 0; o<height; o += spacer) {
    for (int p = 0; p<width; p += spacer) {
      stroke((200-distances[p][o]), (150-distances[p][o]), (150-distances[p][o]));
      point(p + spacer/2, o +spacer/2);
    }
  }
  noStroke();
  smooth();
  randomSeed(1);

  for (int m = 0; m <width; m+= 50) {
    for (int n = 0; n<height; n+= 50) {

      int c = int(random(255));
      //float s = random((m / 1) + 0.5, 3);
      float s = n/400.0 + 0.5;
      int teken = round(random(0, -(n / 300) + 4));
      if (teken != 0) {
        //flower(m + round(random(0, 50)), n + round(random(0, 50)), c, s);
        lines[a][0]=m + round(random(0, 50));
        lines[a][1]=n + round(random(0, 50));
        lines[a][2]=c;
        lines[a][3]=int(s);
      }
      a+=1;
    }
  }
  for (int u=0; u<100; u++) {
    lines(lines[u][0], lines[u][1]);
    d=u;
  }
  for (int u=0; u<400; u++) {

    flower(lines[u][0], lines[u][1], lines[u][2], lines[u][3]);
    noStroke();
  }
}

void lines(int x, float y) {
  line(x, y, lines[d+1][0], lines[d+1][1]);
  stroke(0);
}
void flower(int x, float y, int c, float s) {
  pushMatrix();
  translate(x, y);
  scale(s);
  for (int i = 0; i<5; i++) {
    fill((250+100*i)-c, (80+20*i), 150, 200);
    ellipse(0, -(r-2), r, r);
    rotate(radians(72));
  }
  fill(247, 243, 157);
  ellipse(0, 0, r, r);
  popMatrix();
}