xxxxxxxxxx
int sec=0,min=1,Ts=-1,Tm,MaxM,pulse=50;
float mill = 120;
int prevSec = 0, counter=0;
boolean start=false, pause=false, Fmin=false;
void setup() {
size(700,700);
//fullScreen();
fill(0);
textAlign(CENTER);
noStroke();
background(0);
MaxM=((int)(.016*height));
}
void draw() {
if (start==true) {
fill(0, 30);
rect(0, 0, width, height);
translate(width/2, height/2);
if(Ts==0){
background(0);
for(int i=0;i<360;i+=30){
float x=cos(radians(i));
float y=sin(radians(i));
stroke(255);
strokeWeight(1);
line((x/2)*((120+((23+((MaxM-Tm)*2.5))))-(35)),(y/2)*((120+((23+((MaxM-Tm)*2.5))))-(35)),
(x)*((120+((23+((MaxM-Tm)*2.5))))-(35)),(y)*((120+((23+((MaxM-Tm)*2))))-(35)));
noStroke();
}
fill(255);
textSize(50);
text("0",0,20);
text("press r to reset",0,-height/4);
}
if (sec<0 && min>0) {
min--;
sec=59;
}
if (Ts>0){
if (second()-prevSec < 1 || mill == 120) {
mill-=2;
} else if (second()-prevSec == 1) {
mill = 120;
if(pause==false){
counter++;
sec--;
Ts--;
}
prevSec = second();
} else {
mill-=2;
}
if (mill < 0)mill = 120;
if (second() == 59 && mill == 120) {
prevSec = 0;
}
if (second()==0 && mill==120) {
if(pause==false){
counter++;
Ts--;
sec--;
}
}
for (int j=(Tm-min); j<=Tm; j++) {
for (float i=0; i<360; i+=6) {
//float angle=(sin(radians((i*(j))+frameCount)) * 30)+35; //just try it, I dare you
float angle=35;
float x=cos(radians(i-90));
float y=sin(radians(i-90));
fill(map(i, 0, 360, 0, 255), map(i, 0, 360, 255, 0), 0);
if(pause==false){
if((counter%60)*6==i && j==(Tm-min)){
clockDot(x*((mill+(j*(23+((MaxM-Tm)*2.5))))-(angle)),y*((mill+(j*(23+((MaxM-Tm)*2.5))))-(angle)),(5+(j*1.25)),20+(MaxM-Tm),i);
}
}
if(Ts<=60){
if(i%15==0){
stroke(255);
strokeWeight(.1);
line((x/2)*((120+(j*(23+((MaxM-Tm)*2.5))))-(angle)),(y/2)*((120+(j*(23+((MaxM-Tm)*2.5))))-(angle)),
(x)*((120+(j*(23+((MaxM-Tm)*2.5))))-(angle)),(y)*((120+(j*(23+((MaxM-Tm)*2.5))))-(angle)));
noStroke();
}
}
if((i>(counter%60)*6) && (min<Tm)) {
clockDot(x*((120+(j*(23+((MaxM-Tm)*2.5))))-(angle)), y*((120+(j*(23+((MaxM-Tm)*2.5))))-(angle)), (5+(j*1.25)), 20+(MaxM-Tm),i);
}
if(j>(Tm-min)) {
clockDot(x*((120+(j*(23+((MaxM-Tm)*2.5))))-(angle)),y*((120+(j*(23+((MaxM-Tm)*2.5))))-(angle)),5+(j*1.25),20+(MaxM-Tm),i);
}
}
}
if(Ts<=10 || Ts==30){
fill(0);
ellipse(0,0,66,66);
fill(255);
textSize(50);
text(Ts,0,20);
}
}
}else if(Ts==-1){
translate(width/2, height/2);
background(0);
fill(255);
textSize(50);
String s1=min+"";
float S1=textWidth(s1);
if(Fmin==false){
if(pulse>0){
stroke(255);
}else if(pulse<=0){
stroke(0);
if(pulse==(-50)){
pulse=50;
}
}
line(-(S1/2)+(textWidth(min+"")*1.1),(height/16),-(S1/2),(height/16));
pulse--;
}
text("How many \nminutes:",0,-(height/6));
text(s1, 0, (height/20));
noStroke();
translate(-width, -height);
}
}
void keyPressed(){
if(start==false){
if(Fmin==false){
if(keyCode==UP && min<MaxM){
min++;
}
if(keyCode==DOWN && min>1){
min--;
}
if(keyCode==ENTER){
Ts=sec+(min*60);
Tm=min;
prevSec = second();
start=true;
}
}
}else{
if(key=='r'){
strokeWeight(1);
Ts=-1;
sec=0;
min=Tm;
counter=0;
start=(!start);
//Fmin=(!Fmin);
}
}
}
void mousePressed(){
if(mouseButton==LEFT){
if(start==true){
pause=(!pause);
}
}
}
void clockDot(float x, float y, float w, float h, float angle) {
pushMatrix();
translate(x, y);
rotate(radians(angle));
rect(0, 0, w, h, w);
popMatrix();
}