cronometro clase
int horaobj=14;
int minobj=15;
String diferencia;
void setup(){
size(400,200);
textAlign(CENTER,CENTER);
textSize(32);
fill(255);
background(0);
}
void draw(){
background(0);
diferencia=tiempo();
text("Faltan: "+diferencia,width/2,height/2);
}
String tiempo(){
int hf,mf,sf;
int h=hour();
int m=minute();
int s=second();
sf=60-s;
mf=minobj-m;
hf=horaobj-h;
if(sf>0){
mf=mf-1;
}
if(mf<0) {
mf=60+mf;
hf=hf-1;
}
if(hf<0){
hf=hf+24;
}
return nf(hf,2)+":"+nf(mf,2)+":"+nf(sf,2);
}
Comentarios
Publicar un comentario