This might do the kind of thing you're after. By drawing just the poly (rather than using circles) you can avoid some flicker on the Bangle's unbuffered screen...
It's a good thing to try yourself though if you're interested - it's not that hard to use sin and cos and once you've got the hang of it it's really useful for a bunch of stuff
var n=0;
function drawSlice(from,to) {
var a, res = 24;
var x = 120, y = 120, r1 = 75, r2 = 95;
var poly = [];
for (var i=from*res;i<to*res;i++) {
a = i*Math.PI*2/res;
poly.push(x+r2*Math.sin(a), y+r2*Math.cos(a));
poly.unshift(x+r1*Math.sin(a), y+r1*Math.cos(a));
}
a = to*Math.PI*2;
poly.push(x+r2*Math.sin(a), y+r2*Math.cos(a));
poly.unshift(x+r1*Math.sin(a), y+r1*Math.cos(a));
g.fillPoly(poly);
}
function draw() {
n += 0.01;
if (n>=1) n=0;
g.setColor(1,0,0);
drawSlice(n,1);
g.setColor(0,1,0);
drawSlice(0,n);
}
setInterval(draw, 100);
Hi,
Thanks a lot for encouraging me to try this out and for your suggestions.
I shall definitely try it out.
Thanks so much for your time to share the code example with me as well.
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.
This might do the kind of thing you're after. By drawing just the poly (rather than using circles) you can avoid some flicker on the Bangle's unbuffered screen...
It's a good thing to try yourself though if you're interested - it's not that hard to use sin and cos and once you've got the hang of it it's really useful for a bunch of stuff