Changed my drawString override function to clearRect the area where the string is going to be displayed.
Not extensively tested, but seems to work ok for me. It saves a lot of clearRects in my code :-)
Comments and suggestions welcome!
Code is like this:
// override drawString function to:
// - allocate proper line spacing between successive lines
// - clear the area where the string will be displayed
g._ds = g.drawString;
g.drawString = function(s,x,y) {
s=s.toString();
sa=s.split("\n");
spacing=5+g.getFontHeight();
sa.forEach(function(line){
// clear the area where the string will be written
g.clearRect(x,y,x+g.stringWidth(line), y + spacing);
// now call the original drawString
g._ds(line,x,y);
y+=spacing;
});
};
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.
Changed my
drawString
override function toclearRect
the area where the string is going to be displayed.Not extensively tested, but seems to work ok for me. It saves a lot of
clearRect
s in my code :-)Comments and suggestions welcome!
Code is like this: