Bom, usei a função millis() dividida por 1000 para receber a quantidade de segundos. (a função millis() retorna 1 milésimo de segundos). Como o círculo tem 360º, o ponteiro vai se deslocar 6º por segundo. Criei o desenho de um cronômetro no próprio processing usando círculos e aumentando as bordas. O ponteiro, é basicamente uma linha que sai do centro da tela, e se move de acordo com a posição polar do x e do y da ellipse, nela eu coloquei para o ângulo ser multiplicado pelos segundos
e isso acontece direto por estar dentro do loop draw. Também usei a função radians() converte o valor colocado no parâmetro em graus pra radianos.
int ang = 6;
void setup() {
size(600,600);
}
void draw() {
int segundos = millis()/1000;
background(255);
fill(0,128,128);
ellipse(width/2,height/2,400,400);
fill(204,255,255);
ellipse(width/2,height/2,350,350);
strokeWeight(13);
stroke(0);
line(width/2,height/2,xPolar(150,radians(ang)*segundos)+100,yPolar(150,radians(ang)*segundos) + 300);
}
float xPolar(float raio, float ang) {
float x;
x = raio * cos(ang);
return x;
}
float yPolar(float raio, float ang) {
float y;
y = raio * sin(ang);
return y;
}
e isso acontece direto por estar dentro do loop draw. Também usei a função radians() converte o valor colocado no parâmetro em graus pra radianos.
int ang = 6;
void setup() {
size(600,600);
}
void draw() {
int segundos = millis()/1000;
background(255);
fill(0,128,128);
ellipse(width/2,height/2,400,400);
fill(204,255,255);
ellipse(width/2,height/2,350,350);
strokeWeight(13);
stroke(0);
line(width/2,height/2,xPolar(150,radians(ang)*segundos)+100,yPolar(150,radians(ang)*segundos) + 300);
}
float xPolar(float raio, float ang) {
float x;
x = raio * cos(ang);
return x;
}
float yPolar(float raio, float ang) {
float y;
y = raio * sin(ang);
return y;
}