Entradas

Mostrando entradas de septiembre, 2025

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); }

funciones color

boolean r,v,a; int altura=0; color c; void setup(){   size(800,600);   background(0); } void draw(){   selecolor();   rellenarPantalla(c); } void selecolor(){   if(a){    c=color(0,0,255);    altura=0;    a=false;   }   if(r){    c=color(255,0,0);    altura=0;    r=false;   }   if(v){    c=color(0,255,0);    altura=0;    v=false;   } } void rellenarPantalla(color col) {   stroke(col);   line(0,altura,width,altura);   if(altura<=height){     altura=altura+2;   } } void keyPressed(){   if(key=='a'){     a=true;   }   if(key=='r'){     r=true;   }   if(key=='v'){     v=true;   } }

función distancias

float d; int x1,x2,y1,y2; void setup(){   size(800,600);   frameRate(100);   background(0);   stroke(255);   x1=100;   y1=200;   x2=300;   y2=400; } void draw(){   d=distancia(x1,y1,x2,y2);   text(d,x2-x1,y2-y1/2); } float distancia(int tx1, int ty1, int tx2,int ty2){   float dist;   dist=sqrt(sq(tx2-tx1)+sq(ty2-ty1));   line(tx1,ty1,tx2,ty2);   return dist; }