a problem with my tag cloud
in
Programming Questions
•
1 year ago
hi,
i have a code that i developed a little bit. my goal is making a tag cloud with bubbles, which are floating on screen and when they touch each other, changing the floating direction. when i try to add another bubble on screen, my first bubbles gains more speed. and second bubble doesnt floating in screen. i try to have 5 or more bubbles on screen and they floating to random directions..sorry for my bad english.
- float ne_x = noise(10)*0.5;
- float ne_y = noise(10)*0.5;
- float move_x = noise(1);
- float move_y = noise(1);
- float currentx;
- float currenty;
- float num = 2;
- void setup(){
- size(700, 400);
- //stroke(#D60DFF);
- smooth();
- noStroke();
- //strokeWeight(3);
- currentx = width / 2;
- currenty = height / 2;
- frameRate(320);
- }
- void draw(){
- fill(113,25,10,6);
- // background(#C95F45);
- rect(0, 0, width, height);
- drw(ne_x, ne_y, 30, 30);
- }
- void drw(float pozX, float pozY, int seg, int bub_we) {
- int Segments = seg;
- translate(width * noise(num+10), height * noise(num+50));
- rotate(10 * noise(num+10));
- num = num + 0.001;
- float x[] = new float[Segments];
- float y[] = new float[Segments];
- for (int i=0; i<Segments; i++) {
- float angle = float(i) / float(Segments) * TWO_PI+220;
- float distance = bub_we + 15 * noise(i, frameCount/60.0);
- x[i] = pozX + sin(angle) * distance;
- y[i] = pozY + cos(angle) * distance;
- }
- /*ci_x = ci_x + move_x;
- ci_y = ci_y + move_y;*/
- if(ne_x > width){
- ne_x = width;
- move_x = -move_x;
- }
- if(ne_y > height){
- ne_y = height;
- move_y = -move_y;
- }
- if(ne_x < 0){
- ne_x = 0;
- move_x = -move_x;
- }
- if(ne_y < 0){
- ne_y = 0;
- move_y = -move_y;
- }
- //resetMatrix();
- beginShape();
- fill(#D3E2E5);
- for (int i=0; i<Segments+4; i++) {
- curveVertex(x[i % Segments], y[i % Segments]);
- }
- endShape();
- }
1