Open danielx-art opened 7 years ago
I suggest adding the question or help wanted label to this issue. If you want I could start adding labels to the issues corresponding to what the issue is about. Don't have the ability to do that right now so you would have to do something magical and give me the ability to.
@shiffman
@metacarpo10 Well, I think you got it by now, but here you go: in line 17 you write 2raio_in, twice. This should be 2 raio_in. Near the end you write 2raio (also twice), should be changed to 2 raio. After making this changes it will indeed draw something.
Okay, so I've been trying to generate branches of balls with this code. I've been trying different aproaches since 3 days ago and things do not work for some reason. Please If anyone could take a look I would be very grateful.
`ArrayList galhos = new ArrayList();
float raio_in;
int max_iteracoes = 100;
int it = 0;
void setup(){ size(600,600); background(170); raio_in = width/30; PVector primeira_pos_mae = new PVector(width/2,0); PVector primeiro_aponta = new PVector(0,raio_in*1,2); galhos.add(new bgalho(primeira_pos_mae, primeiro_aponta, raio_in, 1)); //EN: generates the first one;
//EN: Debugging to see if its working noStroke(); fill(255); ellipse(galhos.get(0).pos.x, galhos.get(0).pos.y, 2raio_in, 2raio_in); println(galhos.get(0).pos); }
void draw(){
//EN: shows every object
for(int j=0; j<galhos.size();j++){ galhos.get(j).mostra();
}
//EN: proliferate the ones that are not "mothers" still. for(int k=0; k<galhos.size(); k++){ if(galhos.get(k).mae == false && it<max_iteracoes){ galhos.get(k).prolifera(); } }
}`
and the object:
`class bgalho{
PVector pos = new PVector(); //EN: position PVector aponta = new PVector(); //EN: points somewhere int geracao; float raio; boolean mae = false;
bgalho(PVector mae_pos, PVector mae_apo, float rad, int ger){
}
//prolifera/cresce o galho //EN: proliferate/grow the branch void prolifera(){ float novo_raio = raio*0.9; int nova_ger = geracao+1; galhos.add(new bgalho(pos, aponta, novo_raio, nova_ger)); stroke(1); line(pos.x, pos.y, pos.x +aponta.x, pos.y +aponta.y);
}
void mostra(){ //EN: show function noStroke(); fill(0, 255-geracao); ellipse(pos.x, pos.y, 2raio, 2raio); }
}`