xxxxxxxxxx
float s=0;
float speed;
void setup () {
size(800,800);
background(255);
smooth();
if (second()%5==1||second()%5==2){
s=second()-0.4;
}else{
s=second();
}
speed=0.017;
}
color[] sColor={ #FFFFFF,#FFFF00,#0000FF,#FF0000,#000000};
color taegetColor =#FF0000;
int colorNo=1;
void draw () {
//Draw the background
fill(255);
noStroke();
rect(0,0,width,height);
//背景线条
if (mousePressed){
fill(139,165,120);}
else{fill(210);}
arc(400,400,600,600,PI*5/6,PI*3/2,PIE);
if (mousePressed){
fill(188,211,169);}
else{fill(235);}
arc(400,400,600,600,-HALF_PI,PI/6,PIE);
if (mousePressed){
fill(218,234,204);}
else{fill(245);}
arc(400,400,600,600,PI/6,PI*5/6,PIE);
noFill();
stroke(0);
strokeWeight(0.1);
for (int i=1;i<61;i++){
if(i%5==0){
strokeWeight(0.17);
arc(400,400,i*10,i*10,PI*5/6,PI*13/6);
}else{
strokeWeight(0.1);
arc(400,400,i*10,i*10,-HALF_PI,PI/6);
}
}
//时
noFill();
strokeWeight(0.9);
if (hour()<12){
arc(400,400,50*(hour()),50*(hour()),PI*5/6,PI*3/2,OPEN);
}else{
arc(400,400,50*(hour()-12),50*(hour()-12),PI*5/6,PI*3/2,OPEN);
}
//分
strokeWeight(0.6);
arc(400,400,10*minute(),10*minute(),-HALF_PI,PI/6, OPEN);
//秒
strokeWeight(0.4);
arc(400,400,10*s,10*s,PI/6, PI*5/6, OPEN);
//改变参数
s+=speed;
if (second()%15==0 && second()!=0){
s=second();
}else if (second()==0){
s=0;
}
}
void mousePressed() {
if(colorNo==1)
{
colorNo=2;
}
else if(colorNo==2)
{
colorNo=3;
}
else if(colorNo==3)
{
colorNo=1;
}
taegetColor=sColor[colorNo];
}