I’m struggling to get an ellipse-with-text moving around the screen smoothly. Is it just me or is the text jittering a lot more than the ellipse? It seems like the ellipse shake is minimal/tolerable, but the text shake is not.
Things do smooth out at faster speeds, but I need help decaffeinating the slower speeds.
Thanks for any help!
// right/left arrow keys speed/slow the animation
// other keys show just the text, just the ellipse, or both
void setup() {
size(800, 600);
smooth();
textSize(64);
}
float degrees=0, change=0.05;
int show=3; // 1=ellipse, 2=text, 3=both
void draw() {
background(225);
pushMatrix();
translate(width/2, height/2);
fill(255);
if (show != 2) // 2 == text only
ellipse(cos(radians(degrees)) * 225, sin(radians(degrees)) * 225, 100, 100);
fill(0);
if (show != 1) // 1 == ellipse only
text("OO", cos(radians(degrees)) * 225 - 50, sin(radians(degrees)) * 225 + 25);
popMatrix();
degrees = (degrees + change) % 360;
}
void keyPressed() {
if (keyCode == RIGHT) // speed up
change += 0.05;
else if (keyCode == LEFT) // slow down
change -= 0.05;
else
show = (show + 1) % 3; // change what's being shown
}