• Nice functionaliy, may be you are willing to extend it a little bit:
    I'm struggeling with the Moon Phase Widget ( https://github.com/espruino/BangleApps/t­ree/master/apps/widmp ) to add "the dark side of the moon". Currently it is drawn with a filled circle overlaid by a rectangle to clear it half.
    I'm thinking about using your code to draw a half filled circle, for this it would be nice to add a parameter to disable the rounding of one or several edge(s).
    I know that there are easier ways to draw a half filled circle but with a small modification this function (when hopefully added to the graphics library) will be "more universal".

    My proposal is:

    function drawRoundedRect (x1,y1, x2,y2, r, edgeMask)

    where edgeMask is a bit coded parameter to disable the rounding of an edge (1,2,4,8 - in clockwise order):

    edgeMask = (e.g.)
    0x00 -> (_)
    0x06 -> (_]
    0x09 -> [_)
    0x0F -> [_]

    On the other way round, maybe r and roundMask can be added to the generic drawRect() function (with roundMask to enable rounded edges) but I don't know how Javascript reacts when function parameters are missing.


Avatar for HilmarSt @HilmarSt started