• Actually one other (much better!) method that didn't occur to me until just now is to do two steps, and to use the transparency option when rendering to allow you to render the outside and then the inside of the circle:

    var W = g.getWidth();
    var H = g.getHeight()-24;
    var center = {x:W/2, y:H/2};
    var scale = 1;
    var buf = Graphics.createArrayBuffer(W,H,1,{msb:tr­ue});
    var bufImg = {
      width : W, height : H,
      bpp : 1, buffer : buf.buffer
    };
    
    function drawCircle() {
      buf.fillEllipse(center.x - 5 * scale, center.y - 70 * scale, center.x + 160 * scale, center.y + 90 * scale);
    }
    
    function drawText() {
      var hour = 12;
      var minutes = 34;  
      
      buf.setFontAlign(1, 0).setFont("Vector", 90 * scale);
      buf.drawString(hour, center.x + 32 * scale, center.y - 31 * scale);
      buf.drawString(minutes, center.x + 32 * scale, center.y + 46 * scale);
    }
    
    function draw() {
    
      
      // render entire image with black circle
      buf.setColor(1);
      drawText();
      buf.setColor(0);
      drawCircle();
      delete bufImg.transparent;
      g.drawImage(bufImg,0,24);
      // use transparency to render red bits
      buf.clear().setColor(1);
      drawCircle();
      buf.setColor(0);
      drawText();
      bufImg.transparent = 0;
      g.drawImage(bufImg,0,24);
    }
    
    draw();
    

    There'd still be a moderate amount of flicker in the circle on Bangle.js 1, but I doubt it'd be too much of an issue

About

Avatar for Gordon @Gordon started