Show draw representing Lunar Phase

Former Member
Former Member
Hi,

My question is that I'm trying to show the diferents lunar phases in my own watch face, how can I draw the circle with two colors representing the luna with its phases

Thanks for all and your help
  • Wouldn't it be simpler to just create a handful of bitmaps (one for each moon phase) and then draw the correct one?

    Travis
  • hi everyone, 

    here is a simple function to draw moon phase.

    I use to use of course font for this but this function take not so much as font (depending on how much characters on your font etc)

    the adventage of this function is that on Antialiasing drawing device, the render is pretty cool.

    Hope it wil help some on you.

    Off course if some of you have idea to make it "simpler" or better, let me know.

    function drawMoon(dc,x,y){
    	
    		var A = moonA(0);if(south){A=29.53-A;}
    		var w=gW*0.05;
    		var F=14.765, Q=F/2.0,Q2=F+Q;
    		
    		var s=A<F?0:180;
    		dc.setPenWidth(w);dc.setColor(0xFFFFFF, -1);
    		dc.drawArc(x, y, w/2, 0, 270+s, 90+s);
    		
    		var p = w/Q*(A>F?A-F:A);p=w-p;
    		var c = A<Q||A>Q2?0:0xFFFFFF;
    		dc.setPenWidth(1);dc.setColor(c, -1);
    		dc.fillEllipse(x, y, p.abs(), w);
    		
    		dc.setColor(0xFFFFFF, -1);
    		dc.drawCircle(x, y, w);
    		
    	}

    the function moonA(0) is just the moon age,

    south is a boolean, false if north hemisphere, true if south.

    gW= dc.getWidth, so the var w is the size you want.

    have a great day.