This is the code I use for rounded rects in my programs:
function RectRnd(x1,y1,x2,y2,r) { pp = []; pp.push.apply(pp,g.quadraticBezier([x2-r,y1, x2,y1,x2,y1+r])); pp.push.apply(pp,g.quadraticBezier([x2,y2-r,x2,y2,x2-r,y2])); pp.push.apply(pp,g.quadraticBezier([x1+r,y2,x1,y2,x1,y2-r])); pp.push.apply(pp,g.quadraticBezier([x1,y1+r,x1,y1,x1+r,y1])); return pp; } function fillRectRnd(x1,y1,x2,y2,r,c) { g.setColor(c); g.fillPoly(RectRnd(x1,y1,x2,y2,r),1); g.setColor(255,255,255); } function drawRectRnd(x1,y1,x2,y2,r,c) { g.setColor(c); g.drawPoly(RectRnd(x1,y1,x2,y2,r),1); g.setColor(255,255,255); }
@Ronin 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.
This is the code I use for rounded rects in my programs: