function draw_clock(){
  // first move all the shards down the screen
  for(var i=0; i<this.shards.length; i++){
    var visible = shards[i].isVisible();
    // once the shard is no longer visible we wait
    // a random no of loops before reseting
    if(!visible && Math.random() > RESET_PROBABILITY){
      shards[i].reset();
      shards[i].length = shard_length();
      shards[i].x = shard_x(i);
      if(shards[i].x > DATE_X_COORD - 20){
        shards[i].y = 50;
      }
    }
    // If its still visble then add to the shard and show to screen
    if(visible){
      shards[i].add();
    }
    // we still have to show the shard even though it may be off the screen to keep the speed constant
    shards[i].show();
  }
  var now = new Date();
  // draw time. Have to draw time on every loop

  g.setFont("Vector", g.getWidth() / 5);
  g.setFontAlign(0,-1);
  if(last_draw_time == null || now.getMinutes() != last_draw_time.getMinutes()){
    g.setColor(g.theme.fg);
    g.drawString(timeStr, w/2, TIME_Y_COORD);
    timeStr = format_time(now);
  }
  g.setColor(SHARD_COLOR[0], SHARD_COLOR[1], SHARD_COLOR[2]);
  g.drawString(timeStr, w/2, TIME_Y_COORD); 
  //
  // draw date when it changes
  g.setFont("Vector",15);
  g.setFontAlign(0,-1,0);
  if(last_draw_time == null || now.getDate() != last_draw_time.getDate()){
    g.setColor(g.theme.fg);
    g.drawString(dateStr, w/2, DATE_Y_COORD);
    dateStr = format_date(now);
    g.setColor(SHARD_COLOR[0], SHARD_COLOR[1], SHARD_COLOR[2]);
    g.drawString(dateStr, w/2, DATE_Y_COORD); 
  }
  last_draw_time = now;
}
/**
* main loop to draw the clock face
*/
main loop to draw the clock face
main loop to draw the clock face
function draw_clock(){
  for(var i=0; i<this.shards.length; i++){
    var visible = shards[i].isVisible();
    if(!visible && Math.random() > RESET_PROBABILITY){
      shards[i].reset();
      shards[i].length = shard_length();
      shards[i].x = shard_x(i);
      if(shards[i].x > DATE_X_COORD - 20){
        shards[i].y = 50;
      }
    }
    if(visible){
      shards[i].add();
    }
    shards[i].show();
  }
  var now = new Date();
  g.setFont("Vector", g.getWidth() / 5);
  g.setFontAlign(0,-1);
  if(last_draw_time == null || now.getMinutes() != last_draw_time.getMinutes()){
    g.setColor(g.theme.fg);
    g.drawString(timeStr, w/2, TIME_Y_COORD);
    timeStr = format_time(now);
  }
  g.setColor(SHARD_COLOR[0], SHARD_COLOR[1], SHARD_COLOR[2]);
  g.drawString(timeStr, w/2, TIME_Y_COORD); 
   draw date when it changes
  g.setFont("Vector",15);
  g.setFontAlign(0,-1,0);
  if(last_draw_time == null || now.getDate() != last_draw_time.getDate()){
    g.setColor(g.theme.fg);
    g.drawString(dateStr, w/2, DATE_Y_COORD);
    dateStr = format_date(now);
    g.setColor(SHARD_COLOR[0], SHARD_COLOR[1], SHARD_COLOR[2]);
    g.drawString(dateStr, w/2, DATE_Y_COORD); 
  }
  last_draw_time = now;
}
function draw_clock ( ) { for ( var i = 0 ; i < this . shards . length ; i ++ ) { var visible = shards [ i ] . isVisible ( ) ; if ( ! visible && Math . random ( ) > RESET_PROBABILITY ) { shards [ i ] . reset ( ) ; shards [ i ] . length = shard_length ( ) ; shards [ i ] . x = shard_x ( i ) ; if ( shards [ i ] . x > DATE_X_COORD - 20 ) { shards [ i ] . y = 50 ; } } if ( visible ) { shards [ i ] . add ( ) ; } shards [ i ] . show ( ) ; } var now = new Date ( ) ; g . setFont ( "Vector" , g . getWidth ( ) / 5 ) ; g . setFontAlign ( 0 , - 1 ) ; if ( last_draw_time == null || now . getMinutes ( ) != last_draw_time . getMinutes ( ) ) { g . setColor ( g . theme . fg ) ; g . drawString ( timeStr , w / 2 , TIME_Y_COORD ) ; timeStr = format_time ( now ) ; } g . setColor ( SHARD_COLOR [ 0 ] , SHARD_COLOR [ 1 ] , SHARD_COLOR [ 2 ] ) ; g . drawString ( timeStr , w / 2 , TIME_Y_COORD ) ; g . setFont ( "Vector" , 15 ) ; g . setFontAlign ( 0 , - 1 , 0 ) ; if ( last_draw_time == null || now . getDate ( ) != last_draw_time . getDate ( ) ) { g . setColor ( g . theme . fg ) ; g . drawString ( dateStr , w / 2 , DATE_Y_COORD ) ; dateStr = format_date ( now ) ; g . setColor ( SHARD_COLOR [ 0 ] , SHARD_COLOR [ 1 ] , SHARD_COLOR [ 2 ] ) ; g . drawString ( dateStr , w / 2 , DATE_Y_COORD ) ; } last_draw_time = now ; }
main loop to draw the clock face
main loop to draw the clock face
// first move all the shards down the screen // once the shard is no longer visible we wait // a random no of loops before reseting // If its still visble then add to the shard and show to screen // we still have to show the shard even though it may be off the screen to keep the speed constant // draw time. Have to draw time on every loop // // draw date when it changes