We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am writing this program to plot graphs on screen. However, the rendering is too slow. Any clues how it can be made faster? Here is the code below. It plots a simple Archimedes spiral.
float r=0,a=0,t=0,x0=0,y0=0,x=0,y=0;
int c=80;
void setup(){
size(1024,768);
background(0);
strokeWeight(1);
stroke(c,100,150);
}
void draw(){
translate(width/2,height/2);
if(t<=30*PI)
{
x0=r*cos(a);
y0=r*sin(a);
a=t;//360*(sin(t/20)+0.5*sin(t/40));
r=a;//200*(sin(t/40)+0.5*sin(t/80));
x=r*cos(a);
y=r*sin(a);
line(x0,-y0,x,-y);
t+=0.1;
}
}
Answers
r*cos(a)
&r*sin(a)
.https://OpenProcessing.org/sketch/475427
none of the above matters because you are drawing 30 * PI / .1 things at 60 frames per second, so it'll always take 940 frames, 15 seconds. as long as your draw() completes in 1/60th of a second, which it will, the code can be as sub-optimal as you like.
in short, change the framerate
@GotoLoop That indeed works faster on my lappy, Thanks! Although not very smooth; it's working in pieces completing portions of the curve and then displaying them on screen. Thanks, will study your code now. It's all new to me!