function drawHands(full) {
  var d = new Date();
  var rsec = d.getSeconds()*Math.PI/30;
  var rmin = d.getMinutes()*Math.PI/30;
  // hack so hour hand only moves every 10 minutes
  var rhr = (d.getHours() + Math.round(d.getMinutes()/10)/6)*Math.PI/6;
  var bounds = {};
  if (!full) { // work out the bounds of the hands
    var x1 = (g.getWidth()/2)-10;
    var y1 = (g.getHeight()/2)-10 - 36;
    var x2 = (g.getWidth()/2)+10;
    var y2 = (g.getHeight()/2)+10 - 36;
    function addPt(ang, r, ry) {
      var x = (g.getWidth()/2) + Math.sin(ang)*r + Math.cos(ang)*ry;
      var y = (g.getHeight()/2) - Math.cos(ang)*r + Math.sin(ang)*ry - 36;
      //g.setColor("#ff0000").fillRect(x-2,y-2,x+2,y+2);
      if (x<x1)x1=x;
      if (y<y1)y1=y;
      if (x>x2)x2=x;
      if (y>y2)y2=y;
    }
    function addSec(r) {
      addPt(r,handSizeSec+5,5);addPt(r,handSizeSec+5,-5);
      addPt(r,-(o+10),5);addPt(r,-(o+10),-5);
    }
    function addMin(r) {
      addPt(r,handSizeMin,5);addPt(r,handSizeMin,-5);
      addPt(r,-(o+8),5);addPt(r,-(o+8),-5);
    }
    function addHr(r) {
      addPt(r,handSizeHr,8);addPt(r,handSizeHr,-8);
      addPt(r,-(o+8),8);addPt(r,-(o+8),-8);
    }
    if (rsec!=lastrsec) {
      addSec(rsec);addSec(lastrsec);
    }
    if (rmin!=lastrmin) {
      addMin(rmin);addMin(lastrmin);
    }
    if (rhr!=lastrhr) {
      addHr(rhr);addHr(lastrhr);
    }
    bounds = {x:x1,y:y1,width:1+x2-x1,height:1+y2-y1};
  }

  g.drawImages([
    {image:bgimg,x:20,y:25,scale:2},
    {image:ghrimg,x:120,y:120-31,center:true,rotate:rhr},
    {image:gminimg,x:120,y:120-31,center:true,rotate:rmin},
    {image:gsecimg,x:120,y:120-31,center:true,rotate:rsec}
  ],bounds);
  lastrsec = rsec;
  lastrmin = rmin;
  lastrhr = rhr;

  // Date
  var date = locale.date(new Date(),false);
  if (date === lastDate) return;
  lastDate = date;
  g.reset();
  g.setFont("6x8");
  g.setFontAlign(0,-1);
  g.drawString(date, g.getWidth()/2, 232, true);
}
// draw hands - just the bit of the image that changed
draw hands - just the bit of the image that changed
draw hands - just the bit of the image that changed
function drawHands(full) {
  var d = new Date();
  var rsec = d.getSeconds()*Math.PI/30;
  var rmin = d.getMinutes()*Math.PI/30;
  var rhr = (d.getHours() + Math.round(d.getMinutes()/10)/6)*Math.PI/6;
  var bounds = {};
  if (!full) { 
    var x1 = (g.getWidth()/2)-10;
    var y1 = (g.getHeight()/2)-10 - 36;
    var x2 = (g.getWidth()/2)+10;
    var y2 = (g.getHeight()/2)+10 - 36;
    function addPt(ang, r, ry) {
      var x = (g.getWidth()/2) + Math.sin(ang)*r + Math.cos(ang)*ry;
      var y = (g.getHeight()/2) - Math.cos(ang)*r + Math.sin(ang)*ry - 36;
      if (x<x1)x1=x;
      if (y<y1)y1=y;
      if (x>x2)x2=x;
      if (y>y2)y2=y;
    }
    function addSec(r) {
      addPt(r,handSizeSec+5,5);addPt(r,handSizeSec+5,-5);
      addPt(r,-(o+10),5);addPt(r,-(o+10),-5);
    }
    function addMin(r) {
      addPt(r,handSizeMin,5);addPt(r,handSizeMin,-5);
      addPt(r,-(o+8),5);addPt(r,-(o+8),-5);
    }
    function addHr(r) {
      addPt(r,handSizeHr,8);addPt(r,handSizeHr,-8);
      addPt(r,-(o+8),8);addPt(r,-(o+8),-8);
    }
    if (rsec!=lastrsec) {
      addSec(rsec);addSec(lastrsec);
    }
    if (rmin!=lastrmin) {
      addMin(rmin);addMin(lastrmin);
    }
    if (rhr!=lastrhr) {
      addHr(rhr);addHr(lastrhr);
    }
    bounds = {x:x1,y:y1,width:1+x2-x1,height:1+y2-y1};
  }
  g.drawImages([
    {image:bgimg,x:20,y:25,scale:2},
    {image:ghrimg,x:120,y:120-31,center:true,rotate:rhr},
    {image:gminimg,x:120,y:120-31,center:true,rotate:rmin},
    {image:gsecimg,x:120,y:120-31,center:true,rotate:rsec}
  ],bounds);
  lastrsec = rsec;
  lastrmin = rmin;
  lastrhr = rhr;
  var date = locale.date(new Date(),false);
  if (date === lastDate) return;
  lastDate = date;
  g.reset();
  g.setFont("6x8");
  g.setFontAlign(0,-1);
  g.drawString(date, g.getWidth()/2, 232, true);
}
function drawHands ( full ) { var d = new Date ( ) ; var rsec = d . getSeconds ( ) * Math . PI / 30 ; var rmin = d . getMinutes ( ) * Math . PI / 30 ; var rhr = ( d . getHours ( ) + Math . round ( d . getMinutes ( ) / 10 ) / 6 ) * Math . PI / 6 ; var bounds = { } ; if ( ! full ) { var x1 = ( g . getWidth ( ) / 2 ) - 10 ; var y1 = ( g . getHeight ( ) / 2 ) - 10 - 36 ; var x2 = ( g . getWidth ( ) / 2 ) + 10 ; var y2 = ( g . getHeight ( ) / 2 ) + 10 - 36 ; function addPt ( ang , r , ry ) { var x = ( g . getWidth ( ) / 2 ) + Math . sin ( ang ) * r + Math . cos ( ang ) * ry ; var y = ( g . getHeight ( ) / 2 ) - Math . cos ( ang ) * r + Math . sin ( ang ) * ry - 36 ; if ( x < x1 ) x1 = x ; if ( y < y1 ) y1 = y ; if ( x > x2 ) x2 = x ; if ( y > y2 ) y2 = y ; } function addSec ( r ) { addPt ( r , handSizeSec + 5 , 5 ) ; addPt ( r , handSizeSec + 5 , - 5 ) ; addPt ( r , - ( o + 10 ) , 5 ) ; addPt ( r , - ( o + 10 ) , - 5 ) ; } function addMin ( r ) { addPt ( r , handSizeMin , 5 ) ; addPt ( r , handSizeMin , - 5 ) ; addPt ( r , - ( o + 8 ) , 5 ) ; addPt ( r , - ( o + 8 ) , - 5 ) ; } function addHr ( r ) { addPt ( r , handSizeHr , 8 ) ; addPt ( r , handSizeHr , - 8 ) ; addPt ( r , - ( o + 8 ) , 8 ) ; addPt ( r , - ( o + 8 ) , - 8 ) ; } if ( rsec != lastrsec ) { addSec ( rsec ) ; addSec ( lastrsec ) ; } if ( rmin != lastrmin ) { addMin ( rmin ) ; addMin ( lastrmin ) ; } if ( rhr != lastrhr ) { addHr ( rhr ) ; addHr ( lastrhr ) ; } bounds = { x : x1 , y : y1 , width : 1 + x2 - x1 , height : 1 + y2 - y1 } ; } g . drawImages ( [ { image : bgimg , x : 20 , y : 25 , scale : 2 } , { image : ghrimg , x : 120 , y : 120 - 31 , center : true , rotate : rhr } , { image : gminimg , x : 120 , y : 120 - 31 , center : true , rotate : rmin } , { image : gsecimg , x : 120 , y : 120 - 31 , center : true , rotate : rsec } ] , bounds ) ; lastrsec = rsec ; lastrmin = rmin ; lastrhr = rhr ; var date = locale . date ( new Date ( ) , false ) ; if ( date === lastDate ) return ; lastDate = date ; g . reset ( ) ; g . setFont ( "6x8" ) ; g . setFontAlign ( 0 , - 1 ) ; g . drawString ( date , g . getWidth ( ) / 2 , 232 , true ) ; }
draw hands - just the bit of the image that changed
draw hands - just the bit of the image that changed
// hack so hour hand only moves every 10 minutes // work out the bounds of the hands //g.setColor("#ff0000").fillRect(x-2,y-2,x+2,y+2); // Date