function ellipse(int xm, int ym, int a, int b)
{
var dx = 0;
var dy = b;
var a2 = a*a
var b2 = b*b;
var err = b2-(2*b-1)*a2
var e2; /* Fehler im 1. Schritt */
do {
g.setPixel(xm+dx, ym+dy);
g.setPixel(xm-dx, ym+dy);
g.setPixel(xm-dx, ym-dy);
g.setPixel(xm+dx, ym-dy);
e2 = 2*err;
if (e2 < (2*dx+1)*b2) { dx++; err += (2*dx+1)*b2; }
if (e2 > -(2*dy-1)*a2) { dy--; err -= (2*dy-1)*a2; }
} while (dy >= 0);
while (dx++ < a) {
g.setPixel(xm+dx, ym);
g.setPixel(xm-dx, ym);
}
}
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.
After sneaking and testing, got this:
@Gordon, would it be worth the effort (original source )?
1 Attachment