Ok, the first loop sets an array of 100 times 1, 99 times 2, 98 times 3, until 1 time 100.
This way if you chose a random index you have an ** almost** linear chance to pick lower values. I say ‘almost’, because now I realized that the graphic really has to be parabolic as you can see in the image with code below.
Now I have to.find some a formula that makes it really linear.
Any idea?
And yes, if the code is over complicated, please explain how.
int t;
int res = 45; // resolution
int[] num = new int[1050];
void setup() {
background(255);
size(1000, 600);
for (int i = 1; i <= res; i++) {
for (int j = res; j >= i; j--) {
num[t] = i;
t++;
}
}
for (int i = 0; i <= 1049; i++) {
line(i, height-15*num[i], i, height);
}
}