Help processing GIF

Hi! It does not work to saddle the gif, the balls disappear because it is not necessary, and the radius does not decrease, I attach the code, please see what is wrong!
C10C2019-CA57-4E32-A6DF-24E78946A153

}Preformatted text
float angle;
float w = 36;
float ma;
float maxD;
float ang=0;
float angV=0.1;
void setup() {
size(600, 600, P3D);
frameRate(60);
ellipseMode(CENTER);

ma = atan(1 / sqrt(4));
maxD = dist(0, 0, width / 2, height / 2);
}

void draw() {
background(255);
translate(width/2, height/2-150,+70);
lights();

rotateX(-QUARTER_PI-PI/2);
// rotateY(ma);
rotateY(0);
for (int z = 0; z < height; z += w) {
for (int x = 0; x < width; x += w) {
pushMatrix();

  float d = dist(x, z, width / 2, height / 2);
  float offset = map(d, 5, maxD, -PI,PI);
  float a = angle + offset;
  float h = map(sin(a), -1, 1, 50, 150);
  translate(x - width / 2, h, z - height / 2);

  fill(0);
  // noStroke();
  sphere(10);
  popMatrix();
}
angle+=0.01;

}
noStroke();
fill(255);
float r=map(sin(ang),-1,1,0,600);
rotateX(-PI/4);
ellipse(0,950,r2,r2);
ang+=angV;
angV+=0.00001;
}

Hi @polllynarium,

Welcome to the forum! :wink:

Can you please format correctly your code by using the </> button:

I also have an error at this line:

ellipse(0, 950, r2, r2);

(the variable r2 is not defined)

this works.

maybe the ellipse at the end was covering the spheres?

also, it could be some kind of clipping on the camera


float angle;
float w = 36;
float ma;
float maxD;
float ang=0;
float angV=0.1;

void setup() {
  size(600, 600, P3D);
  //frameRate(60);
  //ellipseMode(CENTER);

  ma = atan(1 / sqrt(4));
  maxD = dist(0, 0, width / 2, height / 2);
}

void draw() {
  background(255);
  translate(width/2, height, -70);
  lights();

  rotateX(-QUARTER_PI-PI/2);
  // rotateY(ma);
  rotateY(0);
  for (int z = 0; z < height; z += w) {
    for (int x = 0; x < width; x += w) {
      pushMatrix();

      float d = dist(x, z, width / 2, height / 2);
      float offset = map(d, 5, maxD, -PI, PI);
      float a = angle + offset;
      float h = map(sin(a), -1, 1, 50, 150);
      translate(x - width / 2, h, z - height / 2);

      fill(222, 0, 0);
      // 
      noStroke();
      sphere(10);
      popMatrix();
    }
    angle+=0.01;
  }

  noStroke();
  fill(255);
  float r=map(sin(ang), -1, 1, 0, 600);
  rotateX(-PI/4);
  // float r2=22; 
  //  ellipse(0, 950, r2, r2);
  //  ellipse(10, 10, r2, r2);

  ang+=angV;
  angV+=0.00001;
}

1 Like

@polllynarium,

Please format your code:
https://discourse.processing.org/faq#format-your-code

I guessed that r2 should be r*2… that is what happens when you post code that is not properly formatted.

Once I corrected that it seemed to work and I created this:
flowers.gif.mov

I did have to make changes to this to center it and I moved the z-axis in the negative direction:

translate(width/2, height/2-150,+70); // I made changes to this

I used saveFrame() and MovieMaker to make the GIF.

The co-ordinate system for P3D is detailed here:

:)