saveFrame problem

#1

Hi there,

I have the strange problem that if I turn on saveFrame my sketch shows something a little different then when turned off. When it’s turned off it looks the way I want it. I feel like with saveFrame on it’s missing the millis effects…

Here’s the code:

static final int NUM = 0120, NEWEST = NUM - 1;
final float[] x = new float[NUM], y = new float[NUM];
PVector center;
float angle;
float radius;

void setup() {
size(1920, 1080);
//size(3840, 2160);

colorMode(RGB, NEWEST);
frameRate(50);
smooth(4);
strokeWeight(2);
background(255);

center = new PVector(width/2, height/2);
PVector point = new PVector(230,230);
float deltaX = center.x - point.x;
float deltaY = center.y - point.y;
angle = atan2(deltaX, deltaY);
radius = dist(center.x, center.y, point.x, point.y);

for (int i = NUM; i-- != 0; x[i] = center.x+ cos(angle)*radius+random(-300,300), y[i] = center.y + sin(angle)*radius+random(-400,400));
}

void draw() {

if (millis() > 18500)
angle += (PI/26.0869);
else {
angle += (PI/26.0869/2);
}

if (millis() < 31000){
background(NEWEST);
for (int i = 0; i != NEWEST;) {
stroke(NEWEST-i);
line(width/2, height/2, x[i] = x[i + 1], y[i] = y[++i]);
}
x[NEWEST] = center.x+ cos(angle)*radius+random(-300,300);
y[NEWEST] = center.y + sin(angle)*radius+random(-400,400);
}
else {

stroke(0);
line(width/2,height/2, center.x+ cos(angle)*radius+random(-300,300),center.y + sin(angle)*radius+random(-400,400));
}

saveFrame(“untitled1_####.png”);

}

Thanks in advance!

#2

please format your code using the

</> code tag

looks like
```
type or paste code here
```


the first idea could be that the multiple file saving ? at every draw loop
( 50 pictures per sec )
takes too much time ( results in low FPS ) so a millis compare ends with different pictures,
possibly here a frameCount better as millis?

2 Likes