Easy Customizable Clock

edited June 2014 in Share Your Work
int ScreenSize=600;
int[] Time=new int[3];
int[] ArcSize=new int[3];
int[] TimeAngle=new int[3];
int[] Color=new int[4];
String DayTime="";

void setup(){
  size(ScreenSize,ScreenSize);
  ArcSize[0]=360/12;
  ArcSize[1]=360/60;
  ArcSize[2]=360/60;
  Color[0]=#FF5500;
  Color[1]=#00B0FF;
  Color[2]=#54FF00;
  Color[3]=#FEFF00;
}

void draw(){
  background(180);

  Time[0]=hour();
  Time[1]=minute();
  Time[2]=second();

  if(Time[0]>=12){DayTime="PM";}
  else if(Time[0]<12){DayTime="AM";}

  for(int I=0;I<3;I++){

  TimeAngle[I]=ArcSize[I]*Time[I];

  fill(#FF9900);
  ellipse(ScreenSize/2,ScreenSize/2,ScreenSize/4*(4-I),ScreenSize/4*(4-I));
  fill(Color[I]);
  arc(ScreenSize/2,ScreenSize/2,ScreenSize/4*(4-I),ScreenSize/4*(4-I),radians(-90+ArcSize[I]/2+TimeAngle[I]),radians(270-ArcSize[I]/2+TimeAngle[I]),PIE);
  }

  fill(Color[3]);
  ellipse(ScreenSize/2,ScreenSize/2,ScreenSize/4,ScreenSize/4);

  fill(0);
  textSize(ScreenSize/10);
  textAlign(CENTER,CENTER);
  text(DayTime,ScreenSize/2,ScreenSize/2); 
}

Comments

  • (The standard is that variables should start with lower case letter. All yours look like class names)

  • looks great!

  • try frameRate(5); in setup() - no point in updating something 60 times a second if it's only changing once a second. your code is maxing out one of my processors for no reason.

    also in setup() try

    smooth();    // smoother circles
    noStroke();  // gets rid of black line around circles
    

    i also have a problem with PIE in line 36

  • edited June 2014

    Ok thanks, but I don't know why you have an error with PIE.

    Excuse my english

Sign In or Register to comment.