Here is an implementation of your moon phase image (based on Bresenham's circle algorithm - yes, I'm able to learn!):

let ScreenWidth = g.getWidth(), CenterX = ScreenWidth/2; let ScreenHeight = g.getHeight(), CenterY = ScreenHeight/2; g.setBgColor('#000000'); g.clear(false); function drawMoonPhase (CenterX,CenterY, Radius, leftFactor,rightFactor) { let x = Radius, y = 0, Error = Radius; g.drawLine(CenterX-leftFactor*x,CenterY, CenterX+rightFactor*x,CenterY); let dx,dy; while (y <= x) { dy = 1 + 2*y; y++; Error -= dy; if (Error < 0) { dx = 1 - 2*x; x--; Error -= dx; } g.drawLine(CenterX-leftFactor*x,CenterY-y, CenterX+rightFactor*x,CenterY-y); g.drawLine(CenterX-leftFactor*x,CenterY+y, CenterX+rightFactor*x,CenterY+y); g.drawLine(CenterX-leftFactor*y,CenterY-x, CenterX+rightFactor*y,CenterY-x); g.drawLine(CenterX-leftFactor*y,CenterY+x, CenterX+rightFactor*y,CenterY+x); } } g.setColor('#FFFFFF'); drawMoonPhase(CenterX,CenterY, 50, 1,-0.5);

leftFactor and rightFactor specify the actual phase that is to be shown:

leftFactor

rightFactor

1

rightFactor = 1

leftFactor = -1

leftFactor = 1

-1

(see GitHub for the current source code and an animated demo)

Have fun!

1 Attachment

Wonderful! Implementation AND documentation within a few minutes :-))

@Andreas_Rozek started

Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.

Andreas_RozekHere is an implementation of your moon phase image (based on Bresenham's circle algorithm - yes, I'm able to learn!):

`leftFactor`

and`rightFactor`

specify the actual phase that is to be shown:`1`

for a full moon`rightFactor = 1`

and start with`leftFactor = -1`

for a waxing moon. Increase`leftFactor`

until`1`

for a full moon`leftFactor = 1`

and start with`rightFactor = 1`

for a waning moon. Decrease`rightFactor`

until`-1`

(see GitHub for the current source code and an animated demo)

Have fun!

1 Attachment